Class DatabaseCreator
java.lang.Object
com.github.cowwoc.digitalocean.resource.DatabaseCreator
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA firewall rule.static final classThe schedule for when maintenance activities may be performed on the cluster.static final classIdentifies a backup to restore from. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the amount of additional storage that is accessible to the cluster.voidadditionalStorageInMiB(int additionalStorageInMiB) Sets the amount of additional storage that is accessible to the cluster.create()Creates a new database cluster.Returns the type of the database.Returns the machine type of the droplet.firewallRule(DatabaseCreator.FirewallRule firewallRule) Adds a firewall rule to the cluster.Returns the cluster's tags.firewallRules(Collection<DatabaseCreator.FirewallRule> firewallRules) Sets the firewall rules of the cluster.name()Returns the name of the cluster.intReturns the number of nodes in the cluster.Returns the ID of the project that the cluster is assigned to.Sets the ID of the project that the cluster is assigned to.Returns the backup to restore data from.voidrestoreFrom(DatabaseCreator.RestoreFrom restoreFrom) Sets the backup to restore data from.Adds a tag to the cluster.tags()Returns the cluster's tags.tags(Collection<String> tags) Sets the tags of the cluster.toString()version()Returns the version number of the database software.Sets the major version number of the database software.vpc()Returns the VPC to deploy the cluster in.Sets the VPC to deploy the cluster in.zone()Returns the zone to create the cluster in.
-
Method Details
-
name
-
databaseType
-
version
Returns the version number of the database software.- Returns:
- an empty string if the unspecified default value should be used
-
version
Sets the major version number of the database software.- Parameters:
version- an empty string if the unspecified default value should be used- Returns:
- this
- Throws:
IllegalArgumentException- ifversioncontains leading or trailing whitespace
-
numberOfStandbyNodes
public int numberOfStandbyNodes()Returns the number of nodes in the cluster. The cluster includes one primary node, and may include one or two standby nodes.- Returns:
- the number of standby nodes
-
dropletType
Returns the machine type of the droplet.- Returns:
- the machine type
-
zone
-
vpc
-
vpc
Sets the VPC to deploy the cluster in.- Parameters:
vpc-nullto deploy the cluster into the zone'sdefaultVPC- Returns:
- this
-
tag
Adds a tag to the cluster.- Parameters:
tag- the tag to add- Returns:
- this
- Throws:
NullPointerException- iftagis nullIllegalArgumentException- if the tag:- contains any characters other than letters, numbers, colons, dashes and underscores.
- is longer than 255 characters.
-
tags
Sets the tags of the cluster.- Parameters:
tags- the tags- Returns:
- this
- Throws:
NullPointerException- iftagsis nullIllegalArgumentException- if any of the tags:- are null.
- contain any characters other than letters, numbers, colons, dashes and underscores.
- is longer than 255 characters.
-
tags
-
projectId
Returns the ID of the project that the cluster is assigned to.- Returns:
- an empty string if the cluster is assigned to the default project
-
projectId
Sets the ID of the project that the cluster is assigned to.- Parameters:
projectId- an empty string to assign the cluster to the default project- Returns:
- this
- Throws:
NullPointerException- ifprojectIdis nullIllegalArgumentException- ifprojectIdcontains leading or trailing whitespace
-
firewallRule
Adds a firewall rule to the cluster.- Parameters:
firewallRule- the rule- Returns:
- this
- Throws:
NullPointerException- ifruleis null
-
firewallRules
Sets the firewall rules of the cluster.- Parameters:
firewallRules- the firewall rules- Returns:
- this
- Throws:
NullPointerException- iffirewallRulesis nullIllegalArgumentException- if any of the rules are null
-
firewallRules
Returns the cluster's tags.- Returns:
- the tags
-
additionalStorageInMiB
public int additionalStorageInMiB()Returns the amount of additional storage that is accessible to the cluster.- Returns:
- the amount in MiB
-
additionalStorageInMiB
public void additionalStorageInMiB(int additionalStorageInMiB) Sets the amount of additional storage that is accessible to the cluster.- Parameters:
additionalStorageInMiB- the amount in MiB- Throws:
IllegalArgumentException- ifadditionalStorageInMiBis negative
-
restoreFrom
Returns the backup to restore data from.- Returns:
nullif no backup will be restored
-
restoreFrom
Sets the backup to restore data from.- Parameters:
restoreFrom-nullto create an empty cluster
-
create
public CreateResult<Database> create() throws AccessDeniedException, IOException, TimeoutException, InterruptedExceptionCreates a new database cluster.- Returns:
- the new or conflicting cluster
- Throws:
IllegalArgumentException- if thedropletTypeis not supported by managed databasesIllegalStateException- if the client is closedAccessDeniedException- if the request exceeded the client's droplet limitIOException- if an I/O error occurs. These errors are typically transient, and retrying the request may resolve the issue.TimeoutException- if the request times out before receiving a response. This might indicate network latency or server overload.InterruptedException- if the thread is interrupted while waiting for a response. This can happen due to shutdown signals.
-
toString
-