Class DatabaseCreator

java.lang.Object
com.github.cowwoc.digitalocean.resource.DatabaseCreator

public final class DatabaseCreator extends Object
Creates a new database cluster.
  • Method Details

    • name

      public String name()
      Returns the name of the cluster.
      Returns:
      the name
    • databaseType

      public DatabaseType databaseType()
      Returns the type of the database.
      Returns:
      the type
    • version

      public String version()
      Returns the version number of the database software.
      Returns:
      an empty string if the unspecified default value should be used
    • version

      public DatabaseCreator version(String 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 - if version 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

      public DropletType.Id dropletType()
      Returns the machine type of the droplet.
      Returns:
      the machine type
    • zone

      public Zone.Id zone()
      Returns the zone to create the cluster in.
      Returns:
      the zone
    • vpc

      public Vpc.Id vpc()
      Returns the VPC to deploy the cluster in.
      Returns:
      null to deploy the cluster into the zone's default VPC
    • vpc

      public DatabaseCreator vpc(Vpc.Id vpc)
      Sets the VPC to deploy the cluster in.
      Parameters:
      vpc - null to deploy the cluster into the zone's default VPC
      Returns:
      this
    • tag

      public DatabaseCreator tag(String tag)
      Adds a tag to the cluster.
      Parameters:
      tag - the tag to add
      Returns:
      this
      Throws:
      NullPointerException - if tag is null
      IllegalArgumentException - if the tag:
      • contains any characters other than letters, numbers, colons, dashes and underscores.
      • is longer than 255 characters.
    • tags

      public DatabaseCreator tags(Collection<String> tags)
      Sets the tags of the cluster.
      Parameters:
      tags - the tags
      Returns:
      this
      Throws:
      NullPointerException - if tags is null
      IllegalArgumentException - if any of the tags:
      • are null.
      • contain any characters other than letters, numbers, colons, dashes and underscores.
      • is longer than 255 characters.
    • tags

      public Set<String> tags()
      Returns the cluster's tags.
      Returns:
      the tags
    • projectId

      public String 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

      public DatabaseCreator projectId(String 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 - if projectId is null
      IllegalArgumentException - if projectId contains leading or trailing whitespace
    • firewallRule

      public DatabaseCreator firewallRule(DatabaseCreator.FirewallRule firewallRule)
      Adds a firewall rule to the cluster.
      Parameters:
      firewallRule - the rule
      Returns:
      this
      Throws:
      NullPointerException - if rule is null
    • firewallRules

      public DatabaseCreator firewallRules(Collection<DatabaseCreator.FirewallRule> firewallRules)
      Sets the firewall rules of the cluster.
      Parameters:
      firewallRules - the firewall rules
      Returns:
      this
      Throws:
      NullPointerException - if firewallRules is null
      IllegalArgumentException - if any of the rules are null
    • firewallRules

      public Set<DatabaseCreator.FirewallRule> 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 - if additionalStorageInMiB is negative
    • restoreFrom

      public DatabaseCreator.RestoreFrom restoreFrom()
      Returns the backup to restore data from.
      Returns:
      null if no backup will be restored
    • restoreFrom

      public void restoreFrom(DatabaseCreator.RestoreFrom restoreFrom)
      Sets the backup to restore data from.
      Parameters:
      restoreFrom - null to create an empty cluster
    • create

      Creates a new database cluster.
      Returns:
      the new or conflicting cluster
      Throws:
      IllegalArgumentException - if the dropletType is not supported by managed databases
      IllegalStateException - if the client is closed
      AccessDeniedException - if the request exceeded the client's droplet limit
      IOException - 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

      public String toString()
      Overrides:
      toString in class Object