github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/rds/v3/instances/Create.go (about) 1 package instances 2 3 import ( 4 "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/build" 6 ) 7 8 type CreateRdsOpts struct { 9 // Specifies the DB instance name. 10 // DB instances of the same type can have same names under the same tenant. 11 // The value must be 4 to 64 characters in length and start with a letter. 12 // It is case-sensitive and can contain only letters, digits, hyphens (-), and underscores (_). 13 Name string `json:"name" required:"true"` 14 // Specifies the database information. 15 Datastore *Datastore `json:"datastore" required:"true"` 16 // Specifies the HA configuration parameters, which are used when creating primary/standby DB instances. 17 Ha *Ha `json:"ha,omitempty"` 18 // Specifies the parameter template ID. 19 ConfigurationId string `json:"configuration_id,omitempty"` 20 // Specifies the database port information. 21 // The MySQL database port ranges from 1024 to 65535 (excluding 12017 and 33071, which are occupied by the RDS system and cannot be used). 22 // The PostgreSQL database port ranges from 2100 to 9500. 23 // The Microsoft SQL Server database port is 1433 or ranges from 2100 to 9500 (excluding 5355 and 5985). 24 // If this parameter is not set, the default value is as follows: 25 // For MySQL, the default value is 3306. 26 // For PostgreSQL, the default value is 5432. 27 // For Microsoft SQL Server, the default value is 1433. 28 Port string `json:"port,omitempty"` 29 // Specifies the database password. 30 // Valid value: 31 // The value cannot be empty and should contain 8 to 32 characters, including uppercase and lowercase letters, digits, and the following special characters: ~!@#%^*-_=+? 32 // You are advised to enter a strong password to improve security, preventing security risks such as brute force cracking. 33 // If provided password will be considered by system as weak, you will receive an error and you should provide stronger password. 34 Password string `json:"password" required:"true"` 35 // Specifies the advanced backup policy. 36 BackupStrategy *BackupStrategy `json:"backup_strategy,omitempty"` 37 // Specifies the key ID for disk encryption. The default value is empty. 38 DiskEncryptionId string `json:"disk_encryption_id,omitempty"` 39 // Specifies the specification code. The value cannot be empty. 40 FlavorRef string `json:"flavor_ref" required:"true"` 41 // Specifies the volume information. 42 Volume *Volume `json:"volume" required:"true"` 43 // Specifies the region ID. The value cannot be empty. 44 Region string `json:"region" required:"true"` 45 // Specifies the AZ ID. If the DB instance is not a single instance, you need to specify an AZ for each node of the instance and separate the AZs with commas (,). For details, see the example. 46 // The value cannot be empty. For details about how to obtain this parameter value, see Regions and Endpoints. 47 AvailabilityZone string `json:"availability_zone" required:"true"` 48 // Specifies the VPC ID. To obtain this parameter value, use either of the following methods: 49 // Method 1: Log in to VPC console and view the VPC ID in the VPC details. 50 // Method 2: See the "Querying VPCs" section in the Virtual Private Cloud API Reference. 51 VpcId string `json:"vpc_id" required:"true"` 52 // Specifies the network ID. To obtain this parameter value, use either of the following methods: 53 // Method 1: Log in to VPC console and click the target subnet on the Subnets page. You can view the network ID on the displayed page. 54 // Method 2: See the "Querying Subnets" section under "APIs" or the "Querying Networks" section under "OpenStack Neutron APIs" in Virtual Private Cloud API Reference. 55 SubnetId string `json:"subnet_id" required:"true"` 56 // Specifies the private IP address of a DB instance. You can use the following methods to obtain the private IP address: 57 // Method 1: Log in to VPC console and click the target subnet on the Subnets page. You can view the subnet CIDR block on the displayed page. 58 // Method 2: See the "Querying Subnets" section under "APIs" in the Virtual Private Cloud API Reference. 59 DataVip string `json:"data_vip,omitempty"` 60 // Specifies the security group which the RDS DB instance belongs to. To obtain this parameter value, use either of the following methods: 61 // Method 1: Log in to VPC console. Choose Access Control > Security Groups in the navigation pane on the left. On the displayed page, click the target security group. You can view the security group ID on the displayed page. 62 // Method 2: See the "Querying Security Groups" section in the Virtual Private Cloud API Reference. 63 SecurityGroupId string `json:"security_group_id" required:"true"` 64 // Specifies the billing information, which is pay-per-use. By default, pay-per-use is used. 65 ChargeInfo *ChargeInfo `json:"charge_info,omitempty"` 66 // This parameter applies only to Microsoft SQL Server DB instances. 67 Collation string `json:"collation,omitempty"` 68 UnchangeableParam *Param `json:"unchangeable_param,omitempty"` 69 } 70 71 type Datastore struct { 72 // Specifies the DB engine. Value: 73 // MySQL 74 // PostgreSQL 75 // SQLServer 76 Type string `json:"type,omitempty"` 77 // Specifies the database version. 78 // MySQL databases support 5.6, 5.7, and 8.0. Example value: 5.7 79 // PostgreSQL databases support 9.5, 9.6, 10, 11, 12, 13 and 14. Example value: 9.6 80 // Microsoft SQL Server databases only support 2014 SE, 2016 SE, 2016 EE, 2017 SE, 2017 EE, 2019 SE and 2109 EE. Example value: 2014_SE 81 // For details about supported database versions, see section Querying Version Information About a DB Engine. 82 Version string `json:"version,omitempty"` 83 // Indicates the complete version number. This parameter is returned only when the DB engine is PostgreSQL. 84 CompleteVersion string `json:"complete_version,omitempty"` 85 } 86 87 type Ha struct { 88 // Specifies the primary/standby or cluster instance type. The value is Ha (case-insensitive). 89 Mode string `json:"mode,omitempty"` 90 // Specifies the replication mode for the standby DB instance. 91 // Value: 92 // For MySQL, the value is async or semisync. 93 // For PostgreSQL, the value is async or sync. 94 // For Microsoft SQL Server, the value is sync. 95 // NOTE 96 // async indicates the asynchronous replication mode. 97 // semisync indicates the semi-synchronous replication mode. 98 // sync indicates the synchronous replication mode. 99 ReplicationMode string `json:"replication_mode,omitempty"` 100 } 101 102 type BackupStrategy struct { 103 // Specifies the backup time window. Automated backups will be triggered during the backup time window. 104 // The value cannot be empty. It must be a valid value in the "hh:mm-HH:MM" format. The current time is in the UTC format. 105 // The HH value must be 1 greater than the hh value. 106 // The values of mm and MM must be the same and must be set to any of the following: 00, 15, 30, or 45. 107 // Example value: 108 // 08:15-09:15 109 // 23:00-00:00 110 StartTime string `json:"start_time" required:"true"` 111 // Specifies the retention days for specific backup files. 112 // The value range is from 0 to 732. If this parameter is not specified or set to 0, the automated backup policy is disabled. To extend the retention period, contact customer service. Automated backups can be retained for up to 2562 days. 113 // NOTICE 114 // Primary/standby DB instances and Cluster DB instances of Microsoft SQL Server do not support disabling the automated backup policy. 115 KeepDays int `json:"keep_days,omitempty"` 116 } 117 118 type Param struct { 119 LowerCaseTableNames string `json:"lower_case_table_names"` 120 } 121 122 func Create(client *golangsdk.ServiceClient, opts CreateRdsOpts) (*CreateRds, error) { 123 b, err := build.RequestBody(opts, "") 124 if err != nil { 125 return nil, err 126 } 127 128 // POST https://{Endpoint}/v3/{project_id}/instances 129 raw, err := client.Post(client.ServiceURL("instances"), b, nil, &golangsdk.RequestOpts{ 130 OkCodes: []int{202}, 131 }) 132 return extra(err, raw) 133 } 134 135 type CreateRds struct { 136 // Indicates the DB instance information. 137 Instance Instance `json:"instance"` 138 // Indicates the ID of the DB instance creation task. 139 JobId string `json:"job_id"` 140 141 OrderId string `json:"order_id"` 142 } 143 144 type Instance struct { 145 // Indicates the DB instance ID. 146 // NOTE 147 // The v3 DB instance ID is incompatible with the v1 DB instance ID. 148 Id string `json:"id"` 149 // Indicates the DB instance name. Indicates the DB instance name. DB instances of the same type can have same names under the same tenant. 150 // The value must be 4 to 64 characters in length and start with a letter. It is case-insensitive and can contain only letters, digits, hyphens (-), and underscores (_). 151 Name string `json:"name"` 152 // Indicates the DB instance status. For example, BUILD indicates that the DB instance is being created. 153 Status string `json:"status"` 154 // Indicates the database information. 155 Datastore Datastore `json:"datastore"` 156 // Indicates the HA configuration parameters. This parameter is returned only when primary/standby DB instances are created 157 Ha Ha `json:"ha"` 158 // Indicates the parameter template ID. This parameter is returned only when a custom parameter template is used during DB instance creation. 159 ConfigurationId string `json:"configuration_id"` 160 // Indicates the database port, which is the same as the request parameter. 161 Port string `json:"port"` 162 // Indicates the automated backup policy. 163 BackupStrategy BackupStrategy `json:"backup_strategy"` 164 // Indicates the key ID for disk encryption. By default, this parameter is empty and is returned only when it is specified during the DB instance creation. 165 DiskEncryptionId string `json:"disk_encryption_id"` 166 // Indicates the specification code. The value cannot be empty. 167 FlavorRef string `json:"flavor_ref"` 168 // Indicates the volume information. 169 Volume Volume `json:"volume"` 170 // Indicates the region ID. 171 Region string `json:"region"` 172 // Indicates the AZ ID. 173 AvailabilityZone string `json:"availability_zone"` 174 // Indicates the VPC ID. To obtain this parameter value, use either of the following methods: 175 // Method 1: Log in to VPC console and view the VPC ID in the VPC details. 176 // Method 2: See the "Querying VPCs" section in the Virtual Private Cloud API Reference. 177 VpcId string `json:"vpc_id"` 178 // Indicates the network ID. To obtain this parameter value, use either of the following methods: 179 // Method 1: Log in to VPC console and click the target subnet on the Subnets page. You can view the network ID on the displayed page. 180 // Method 2: See the "Querying Subnets" section under "APIs" or the "Querying Networks" section under "OpenStack Neutron APIs" in Virtual Private Cloud API Reference. 181 SubnetId string `json:"subnet_id"` 182 // Indicates the security group which the RDS DB instance belongs to. To obtain this parameter value, use either of the following methods: 183 // Method 1: Log in to VPC console. Choose Access Control > Security Groups in the navigation pane on the left. On the displayed page, click the target security group. You can view the security group ID on the displayed page. 184 // Method 2: See the "Querying Security Groups" section in the Virtual Private Cloud API Reference. 185 SecurityGroupId string `json:"security_group_id"` 186 // Indicates the billing information, which is pay-per-use. 187 ChargeInfo ChargeInfo `json:"charge_info"` 188 // Indicates the Collation set for Microsoft SQL Server. 189 Collation string `json:"collation"` 190 }