Class DatabaseCreator
java.lang.Object
com.github.cowwoc.digitalocean.resource.DatabaseCreator
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
A firewall rule.static final class
The schedule for when maintenance activities may be performed on the cluster.static final class
Identifies a backup to restore from. -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the amount of additional storage that is accessible to the cluster.void
additionalStorageInMiB
(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.int
Returns 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.void
restoreFrom
(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
- ifversion
contains 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
-null
to deploy the cluster into the zone'sdefault
VPC- Returns:
- this
-
tag
Adds a tag to the cluster.- Parameters:
tag
- the tag to add- Returns:
- this
- Throws:
NullPointerException
- iftag
is 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
- iftags
is 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
- ifprojectId
is nullIllegalArgumentException
- ifprojectId
contains leading or trailing whitespace
-
firewallRule
Adds a firewall rule to the cluster.- Parameters:
firewallRule
- the rule- Returns:
- this
- Throws:
NullPointerException
- ifrule
is null
-
firewallRules
Sets the firewall rules of the cluster.- Parameters:
firewallRules
- the firewall rules- Returns:
- this
- Throws:
NullPointerException
- iffirewallRules
is 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
- ifadditionalStorageInMiB
is negative
-
restoreFrom
Returns the backup to restore data from.- Returns:
null
if no backup will be restored
-
restoreFrom
Sets the backup to restore data from.- Parameters:
restoreFrom
-null
to 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 thedropletType
is 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
-