网络
虚拟私有云 VPC
弹性公网IP EIP
弹性负载均衡 ELB
NAT网关 NAT
云专线 DC
虚拟专用网络 VPN
云连接 CC
VPC终端节点 VPCEP
企业路由器 ER
企业交换机 ESW
全球加速 GA
企业连接 EC
云原生应用网络 ANC
安全与合规
安全技术与应用
Web应用防火墙 WAF
企业主机安全 HSS
云防火墙 CFW
安全云脑 SecMaster
DDoS防护 AAD
数据加密服务 DEW
数据库安全服务 DBSS
云堡垒机 CBH
数据安全中心 DSC
云证书管理服务 CCM
认证测试中心 CTC
边缘安全 EdgeSec
应用中间件
微服务引擎 CSE
分布式消息服务Kafka版
分布式消息服务RabbitMQ版
分布式消息服务RocketMQ版
API网关 APIG
分布式缓存服务 DCS
多活高可用服务 MAS
事件网格 EG
管理与监管
统一身份认证服务 IAM
消息通知服务 SMN
云监控服务 CES
应用运维管理 AOM
应用性能管理 APM
云日志服务 LTS
云审计服务 CTS
标签管理服务 TMS
配置审计 Config
应用身份管理服务 OneAccess
资源访问管理 RAM
组织 Organizations
资源编排服务 RFS
优化顾问 OA
IAM 身份中心
云运维中心 COC
资源治理中心 RGC
解决方案
高性能计算 HPC
SAP
混合云灾备
开天工业工作台 MIW
Haydn解决方案工厂
数字化诊断治理专家服务
云生态
云商店
合作伙伴中心
华为云开发者学堂
华为云慧通差旅
开发与运维
软件开发生产线 CodeArts
需求管理 CodeArts Req
流水线 CodeArts Pipeline
代码检查 CodeArts Check
编译构建 CodeArts Build
部署 CodeArts Deploy
测试计划 CodeArts TestPlan
制品仓库 CodeArts Artifact
移动应用测试 MobileAPPTest
CodeArts IDE Online
开源镜像站 Mirrors
性能测试 CodeArts PerfTest
应用管理与运维平台 ServiceStage
云应用引擎 CAE
开源治理服务 CodeArts Governance
华为云Astro轻应用
CodeArts IDE
Astro工作流 AstroFlow
代码托管 CodeArts Repo
漏洞管理服务 CodeArts Inspector
联接 CodeArtsLink
软件建模 CodeArts Modeling
Astro企业应用 AstroPro
CodeArts 盘古助手
华为云Astro大屏应用
计算
弹性云服务器 ECS
Flexus云服务
裸金属服务器 BMS
云手机服务器 CPH
专属主机 DeH
弹性伸缩 AS
镜像服务 IMS
函数工作流 FunctionGraph
云耀云服务器(旧版)
VR云渲游平台 CVR
Huawei Cloud EulerOS
云化数据中心 CloudDC
网络
虚拟私有云 VPC
弹性公网IP EIP
弹性负载均衡 ELB
NAT网关 NAT
云专线 DC
虚拟专用网络 VPN
云连接 CC
VPC终端节点 VPCEP
企业路由器 ER
企业交换机 ESW
全球加速 GA
企业连接 EC
云原生应用网络 ANC
CDN与智能边缘
内容分发网络 CDN
智能边缘云 IEC
智能边缘平台 IEF
CloudPond云服务
安全与合规
安全技术与应用
Web应用防火墙 WAF
企业主机安全 HSS
云防火墙 CFW
安全云脑 SecMaster
DDoS防护 AAD
数据加密服务 DEW
数据库安全服务 DBSS
云堡垒机 CBH
数据安全中心 DSC
云证书管理服务 CCM
认证测试中心 CTC
边缘安全 EdgeSec
大数据
MapReduce服务 MRS
数据湖探索 DLI
表格存储服务 CloudTable
可信智能计算服务 TICS
推荐系统 RES
云搜索服务 CSS
数据可视化 DLV
数据接入服务 DIS
数据仓库服务 GaussDB(DWS)
数据治理中心 DataArts Studio
湖仓构建 LakeFormation
智能数据洞察 DataArts Insight
应用中间件
微服务引擎 CSE
分布式消息服务Kafka版
分布式消息服务RabbitMQ版
分布式消息服务RocketMQ版
API网关 APIG
分布式缓存服务 DCS
多活高可用服务 MAS
事件网格 EG
开天aPaaS
应用平台 AppStage
开天企业工作台 MSSE
开天集成工作台 MSSI
API中心 API Hub
云消息服务 KooMessage
交换数据空间 EDS
云地图服务 KooMap
云手机服务 KooPhone
组织成员账号 OrgID
云空间服务 KooDrive
管理与监管
统一身份认证服务 IAM
消息通知服务 SMN
云监控服务 CES
应用运维管理 AOM
应用性能管理 APM
云日志服务 LTS
云审计服务 CTS
标签管理服务 TMS
配置审计 Config
应用身份管理服务 OneAccess
资源访问管理 RAM
组织 Organizations
资源编排服务 RFS
优化顾问 OA
IAM 身份中心
云运维中心 COC
资源治理中心 RGC
区块链
区块链服务 BCS
数字资产链 DAC
华为云区块链引擎服务 HBS
解决方案
高性能计算 HPC
SAP
混合云灾备
开天工业工作台 MIW
Haydn解决方案工厂
数字化诊断治理专家服务
价格
成本优化最佳实践
专属云商业逻辑
云生态
云商店
合作伙伴中心
华为云开发者学堂
华为云慧通差旅
其他
管理控制台
消息中心
产品价格详情
系统权限
客户关联华为云合作伙伴须知
公共问题
宽限期保留期
奖励推广计划
活动
云服务信任体系能力说明
开发与运维
软件开发生产线 CodeArts
需求管理 CodeArts Req
流水线 CodeArts Pipeline
代码检查 CodeArts Check
编译构建 CodeArts Build
部署 CodeArts Deploy
测试计划 CodeArts TestPlan
制品仓库 CodeArts Artifact
移动应用测试 MobileAPPTest
CodeArts IDE Online
开源镜像站 Mirrors
性能测试 CodeArts PerfTest
应用管理与运维平台 ServiceStage
云应用引擎 CAE
开源治理服务 CodeArts Governance
华为云Astro轻应用
CodeArts IDE
Astro工作流 AstroFlow
代码托管 CodeArts Repo
漏洞管理服务 CodeArts Inspector
联接 CodeArtsLink
软件建模 CodeArts Modeling
Astro企业应用 AstroPro
CodeArts 盘古助手
华为云Astro大屏应用
存储
对象存储服务 OBS
云硬盘 EVS
云备份 CBR
高性能弹性文件服务 SFS Turbo
弹性文件服务 SFS
存储容灾服务 SDRS
云硬盘备份 VBS
云服务器备份 CSBS
数据快递服务 DES
云存储网关 CSG
专属分布式存储服务 DSS
数据工坊 DWR
地图数据 MapDS
键值存储服务 KVS
容器
云容器引擎 CCE
云容器实例 CCI
容器镜像服务 SWR
云原生服务中心 OSC
应用服务网格 ASM
华为云UCS
数据库
云数据库 RDS
数据复制服务 DRS
文档数据库服务 DDS
分布式数据库中间件 DDM
云数据库 GaussDB
云数据库 GeminiDB
数据管理服务 DAS
数据库和应用迁移 UGO
云数据库 TaurusDB
人工智能
AI开发平台ModelArts
华为HiLens
图引擎服务 GES
图像识别 Image
文字识别 OCR
自然语言处理 NLP
内容审核 Moderation
图像搜索 ImageSearch
医疗智能体 EIHealth
企业级AI应用开发专业套件 ModelArts Pro
人脸识别服务 FRS
对话机器人服务 CBS
语音交互服务 SIS
人证核身服务 IVS
视频智能分析服务 VIAS
城市智能体
自动驾驶云服务 Octopus
盘古大模型 PanguLargeModels
IoT物联网
设备接入 IoTDA
全球SIM联接 GSL
IoT数据分析 IoTA
路网数字化服务 DRIS
IoT边缘 IoTEdge
设备发放 IoTDP
企业应用
域名注册服务 Domains
云解析服务 DNS
企业门户 EWP
ICP备案
商标注册
华为云WeLink
华为云会议 Meeting
隐私保护通话 PrivateNumber
语音通话 VoiceCall
消息&短信 MSGSMS
云管理网络
SD-WAN 云服务
边缘数据中心管理 EDCM
云桌面 Workspace
应用与数据集成平台 ROMA Connect
ROMA资产中心 ROMA Exchange
API全生命周期管理 ROMA API
政企自服务管理 ESM
视频
实时音视频 SparkRTC
视频直播 Live
视频点播 VOD
媒体处理 MPC
视频接入服务 VIS
数字内容生产线 MetaStudio
迁移
主机迁移服务 SMS
对象存储迁移服务 OMS
云数据迁移 CDM
迁移中心 MGC
专属云
专属计算集群 DCC
开发者工具
SDK开发指南
API签名指南
DevStar
华为云命令行工具服务 KooCLI
Huawei Cloud Toolkit
CodeArts API
云化转型
云架构中心
云采用框架
用户服务
账号中心
费用中心
成本中心
资源中心
企业管理
工单管理
客户运营能力
国际站常见问题
支持计划
专业服务
合作伙伴支持计划
我的凭证
华为云公共事业服务云平台
工业软件
工业数字模型驱动引擎
硬件开发工具链平台云服务
工业数据转换引擎云服务

创建数据库实例

更新时间:2024-12-11 GMT+08:00
分享

功能介绍

创建云数据库TaurusDB实例。

调用方法

请参见如何调用API

URI

POST /v3/{project_id}/instances

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

租户在某一Region下的project ID。

获取方法请参见获取项目ID

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

用户Token。

通过调用IAM服务获取用户Token接口获取。

请求响应成功后在响应消息头中包含的“X-Subject-Token”的值即为Token值。

X-Language

String

请求语言类型。默认en-us。

取值范围:

  • en-us

  • zh-cn

表3 请求Body参数

参数

是否必选

参数类型

描述

region

String

区域ID。

name

String

实例名称。用于表示实例的名称,同一租户下,同类型的实例名可重名。

取值范围:最小为4个字符,最大为64个字符且不超过64个字节(注意:一个中文字符占用3个字节),必须以字母或中文开头,区分大小写,可以包含字母、数字、中划线、下划线或中文,不能包含其他特殊字符。

datastore

MysqlDatastoreInReq object

数据库信息。

mode

String

实例类型,目前仅支持Cluster。

flavor_ref

String

规格码。使用可参考查询数据库规格响应消息表5中的“spec_code”。

vpc_id

String

虚拟私有云ID,获取方法如下:

  • 方法1:登录虚拟私有云服务的控制台界面,在虚拟私有云的详情页面查找VPC ID。

  • 方法2:通过虚拟私有云服务的API接口查询,具体操作可参考查询VPC列表

subnet_id

String

子网的网络ID,获取方法如下:

  • 方法1:登录虚拟私有云服务的控制台界面,单击VPC下的子网,进入子网详情页面,查找网络ID。

  • 方法2:通过虚拟私有云服务的API接口查询,具体操作可参考查询子网列表

password

String

数据库密码。

取值范围:至少包含以下字符的三种:大小写字母、数字和特殊符号|.~!@#$%^*-_=+?,()&,长度8~32个字符。

建议您输入高强度密码,以提高安全性,防止出现密码被暴力破解等安全风险。如果您输入弱密码,系统会自动判定密码非法。

availability_zone_mode

String

可用区类型。

取值范围:

  • single:单可用区。

  • multi:多可用区。

slave_count

Integer

只读节点个数。单次接口调用最多支持创建9个只读节点。

charge_info

MysqlChargeInfo object

计费类型信息,支持包年包月和按需,默认为按需。

说明:DeC专属云账号不支持创建包年/包月实例。

security_group_id

String

安全组ID。如果实例所选用的子网开启网络ACL进行访问控制,则该参数非必选。如果未开启ACL进行访问控制,则该参数必选。获取方法如下:

  • 方法1:登录虚拟私有云服务的控制台界面,在安全组的详情页面查找安全组ID。

  • 方法2:通过虚拟私有云服务的API接口查询,具体操作可参考查询安全组列表

configuration_id

String

参数模板ID。使用可参考查询参数模板中响应消息表5的“id”。

backup_strategy

MysqlBackupStrategy object

自动备份策略。

time_zone

String

时区。默认时区为UTC。

master_availability_zone

String

主可用区ID,创建单可用区实例选填,多可用区实例必填,请参考地区和终端节点

volume

MysqlVolume object

volume信息。创建包年/包月实例可选。创建按需实例时不可选。

tags

Array of MysqlTags objects

标签列表,根据标签键值对创建实例。

  • {key}表示标签键,不可以为空或重复。

  • {value}表示标签值,可以为空。

如果创建实例时同时使用多个标签键值对,中间使用逗号分隔开,最多包含10组。

lower_case_table_names

Integer

表名大小写是否敏感,默认值是1。

取值范围:

  • 0:表名被存储成固定且表名称大小写敏感。

  • 1:表名将被存储成小写且表名称大小写不敏感。

enterprise_project_id

String

企业项目ID。如果账户开通企业项目服务则该参数必选,未开启该参数不可选。

dedicated_resource_id

String

专属资源池ID,只有开通专属资源池后才支持此参数。

restore_point

MysqlRestorePoint object

备份恢复信息。

tde_info

MysqlTdeInfo object

透明数据加密配置信息,支持AES256、SM4加密算法。

透明加密功能目前处于公测阶段,如需使用,请提交工单联系客服人员申请权限。

表4 MysqlDatastoreInReq

参数

是否必选

参数类型

描述

type

String

数据库引擎,现在只支持gaussdb-mysql。

version

String

数据库版本。

两位数的大版本号,获取方法请参见查询数据库引擎的版本返回的name字段。

kernel_version

String

内核数据库版本。如果需要指定具体的内核版本,请联系客服人员添加白名单。

完整的四位内核数据库版本,获取方法请参见查询数据库引擎的版本返回的kernel_version字段。

表5 MysqlChargeInfo

参数

是否必选

参数类型

描述

charge_mode

String

计费模式。

取值范围:

  • prePaid:预付费,即包年/包月。

  • postPaid:后付费,即按需付费。

period_type

String

订购周期类型。

取值范围:

  • month:包月。

  • year:包年。

说明:“charge_mode”为“prePaid”时生效,且为必选值。

period_num

Integer

“charge_mode”为“prePaid”时生效,且为必选值,指定订购的时间。

取值范围:

  • “period_type”为“month”时,取值为1~9。

  • “period_type”为“year”时,取值为1~3。

is_auto_renew

String

创建包年/包月实例时可指定,表示是否自动续订,续订的周期和原周期相同,且续订时会自动支付。

  • true:为自动续订。

  • false:为不自动续订,默认该方式。

is_auto_pay

String

创建包年/包月实例时可指定,表示是否自动从客户的账户中支付,此字段不影响自动续订的支付方式。

  • true:为自动支付,默认该方式。

  • false:为手动支付。

表6 MysqlBackupStrategy

参数

是否必选

参数类型

描述

start_time

String

自动备份开始时间段。自动备份将在该时间一个小时内触发。

取值范围:非空,格式必须为hh:mm-HH:MM且有效,当前时间指UTC时间。

  1. HH取值必须比hh大1。

  2. mm和MM取值必须相同,且取值必须为00。

keep_days

String

自动备份保留天数,取值范围:1-732。

表7 MysqlVolume

参数

是否必选

参数类型

描述

size

String

磁盘大小。默认值为10,单位GB。

取值范围:10~128000,必须为10的整数倍。

表8 MysqlTags

参数

是否必选

参数类型

描述

key

String

标签键。最大长度36个unicode字符。key不能为空或者空字符串,不能为空格。

字符集:A-Z,a-z ,0-9,‘-’,‘_’,UNICODE字符(\u4E00-\u9FFF)。

value

String

标签值。最大长度43个unicode字符。可以为空字符串。

字符集:A-Z,a-z ,0-9,‘.’,‘-’,‘_’,UNICODE字符(\u4E00-\u9FFF)。

表9 MysqlRestorePoint

参数

是否必选

参数类型

描述

source_instance_id

String

源实例ID。

restore_time

Long

需要恢复的时间点。(Point-In-Time Recovery, PITR)。

backup_id

String

备份文件ID。

type

String

备份类型。当参数为空时,backup_id不能为空,即默认按备份文件恢复。

当参数不为空时,取值范围:

  • backup:表示按备份文件恢复。

  • timestamp:表示按时间点恢复。

表10 MysqlTdeInfo

参数

是否必选

参数类型

描述

enable_tde

Boolean

是否打开透明加密功能。

encryption_type

String

透明加密算法,支持AES256、SM4加密算法。

响应参数

状态码: 201

表11 响应Body参数

参数

参数类型

描述

instance

MysqlInstanceResponse object

实例信息

job_id

String

实例创建的任务ID。

仅创建按需实例时会返回该参数。

order_id

String

订单号,创建包年包月时返回该参数。

表12 MysqlInstanceResponse

参数

参数类型

描述

id

String

实例ID,严格匹配UUID规则。

name

String

实例名称。用于表示实例的名称。

status

String

实例状态。

datastore

MysqlDatastoreInRes object

数据库信息。

mode

String

实例类型,仅支持Cluster。

configuration_id

String

参数组ID。

port

String

数据库端口信息。

backup_strategy

MysqlBackupStrategy object

自动备份策略。

enterprise_project_id

String

企业项目ID。

region

String

区域ID,与请求参数相同。

availability_zone_mode

String

可用区模式,与请求参数相同。

master_availability_zone

String

主可用区ID。

vpc_id

String

虚拟私有云ID,与请求参数相同。

security_group_id

String

安全组ID,与请求参数相同。

subnet_id

String

子网ID,与请求参数相同。

flavor_ref

String

规格码,与请求参数相同。

charge_info

MysqlChargeInfo object

计费类型信息,支持包年包月和按需,默认为按需。

volume

MysqlVolumeResp object

volume信息。创建包年/包月实例有返回。

表13 MysqlDatastoreInRes

参数

参数类型

描述

type

String

数据库引擎,现在只支持gaussdb-mysql。

version

String

数据库版本。

kernel_version

String

内核数据库版本。

表14 MysqlBackupStrategy

参数

参数类型

描述

start_time

String

自动备份开始时间段。自动备份将在该时间一个小时内触发。

取值范围:非空,格式必须为hh:mm-HH:MM且有效,当前时间指UTC时间。

  1. HH取值必须比hh大1。

  2. mm和MM取值必须相同,且取值必须为00。

keep_days

String

自动备份保留天数,取值范围:1-732。

表15 MysqlChargeInfo

参数

参数类型

描述

charge_mode

String

计费模式。

取值范围:

  • prePaid:预付费,即包年/包月。

  • postPaid:后付费,即按需付费。

period_type

String

订购周期类型。

取值范围:

  • month:包月。

  • year:包年。

说明:“charge_mode”为“prePaid”时生效,且为必选值。

period_num

Integer

“charge_mode”为“prePaid”时生效,且为必选值,指定订购的时间。

取值范围:

  • “period_type”为“month”时,取值为1~9。

  • “period_type”为“year”时,取值为1~3。

is_auto_renew

String

创建包年/包月实例时可指定,表示是否自动续订,续订的周期和原周期相同,且续订时会自动支付。

  • true:为自动续订。

  • false:为不自动续订,默认该方式。

is_auto_pay

String

创建包年/包月实例时可指定,表示是否自动从客户的账户中支付,此字段不影响自动续订的支付方式。

  • true:为自动支付,默认该方式。

  • false:为手动支付。

表16 MysqlVolumeResp

参数

参数类型

描述

size

Integer

磁盘大小。单位GB。

取值范围:10~128000,为10的整数倍。

状态码: 400

表17 响应Body参数

参数

参数类型

描述

error_code

String

错误码。

error_msg

String

错误消息。

状态码: 500

表18 响应Body参数

参数

参数类型

描述

error_code

String

错误码。

error_msg

String

错误消息。

请求示例

  • 创建计费模式为按需计费,自动备份开始时间是08:00-09:00的实例。

    POST https://{endpoint}/v3/054e292c9880d4992f02c0196d3ea468/instances
    
    {
      "name" : "gaussdb-mysql-instance1",
      "region" : "br-iaas-odin1",
      "charge_info" : {
        "charge_mode" : "postPaid"
      },
      "datastore" : {
        "type" : "gaussdb-mysql",
        "version" : "8.0"
      },
      "mode" : "Cluster",
      "flavor_ref" : "gaussdb.mysql.xlarge.arm.4",
      "vpc_id" : "3cedfc54-b105-4652-a4e0-847b11576b58",
      "subnet_id" : "c1cfa53c-65d3-431e-8552-326bf310c7ad",
      "security_group_id" : "fc577a1a-f202-424a-977f-24faec3fdd55",
      "configuration_id" : "43570e0de32e40c5a15f831aa5ce4176pr07",
      "password" : "***",
      "backup_strategy" : {
        "start_time" : "08:00-09:00"
      },
      "availability_zone_mode" : "single",
      "slave_count" : 1,
      "enterprise_project_id" : 0
    }
  • 将备份文件恢复到按需计费的新实例。

    POST https://{endpoint}/v3/054e292c9880d4992f02c0196d3ea468/instances
    
    {
      "name" : "gaussdb-mysql-instance2",
      "region" : "br-iaas-odin1",
      "charge_info" : {
        "charge_mode" : "postPaid"
      },
      "datastore" : {
        "type" : "gaussdb-mysql",
        "version" : "8.0"
      },
      "mode" : "Cluster",
      "flavor_ref" : "gaussdb.mysql.xlarge.arm.4",
      "vpc_id" : "3cedfc54-b105-4652-a4e0-847b11576b58",
      "subnet_id" : "c1cfa53c-65d3-431e-8552-326bf310c7ad",
      "security_group_id" : "fc577a1a-f202-424a-977f-24faec3fdd55",
      "configuration_id" : "43570e0de32e40c5a15f831aa5ce4176pr07",
      "password" : "***",
      "backup_strategy" : {
        "start_time" : "08:00-09:00"
      },
      "availability_zone_mode" : "single",
      "slave_count" : 1,
      "enterprise_project_id" : 0,
      "restore_point" : {
        "source_instance_id" : "7033e7c3cf93438797d44ad7ae0a7d95in07",
        "backup_id" : "7ffbf305376b4cbea0ae491257b6aaf9br07",
        "type" : "backup"
      }
    }
  • 按时间点恢复到按需计费的新实例。

    POST https://{endpoint}/v3/054e292c9880d4992f02c0196d3ea468/instances
    
    {
      "name" : "gaussdb-mysql-instance3",
      "region" : "br-iaas-odin1",
      "charge_info" : {
        "charge_mode" : "postPaid"
      },
      "datastore" : {
        "type" : "gaussdb-mysql",
        "version" : "8.0"
      },
      "mode" : "Cluster",
      "flavor_ref" : "gaussdb.mysql.xlarge.arm.4",
      "vpc_id" : "3cedfc54-b105-4652-a4e0-847b11576b58",
      "subnet_id" : "c1cfa53c-65d3-431e-8552-326bf310c7ad",
      "security_group_id" : "fc577a1a-f202-424a-977f-24faec3fdd55",
      "configuration_id" : "43570e0de32e40c5a15f831aa5ce4176pr07",
      "password" : "***",
      "backup_strategy" : {
        "start_time" : "08:00-09:00"
      },
      "availability_zone_mode" : "single",
      "slave_count" : 1,
      "enterprise_project_id" : 0,
      "restore_point" : {
        "source_instance_id" : "7033e7c3cf93438797d44ad7ae0a7d95in07",
        "restore_time" : 1673852043000,
        "type" : "timestamp"
      }
    }
  • 创建周期为一个月的包年/包月实例。

    POST https://{endpoint}/v3/054e292c9880d4992f02c0196d3ea468/instances
    
    {
      "name" : "gaussdb-mysql-instance4",
      "region" : "br-iaas-odin1",
      "charge_info" : {
        "charge_mode" : "prePaid",
        "period_type" : "month",
        "period_num" : 1,
        "is_auto_renew" : false,
        "is_auto_pay" : true
      },
      "volume" : {
        "size" : 10
      },
      "datastore" : {
        "type" : "gaussdb-mysql",
        "version" : "8.0"
      },
      "mode" : "Cluster",
      "flavor_ref" : "gaussdb.mysql.xlarge.arm.4",
      "vpc_id" : "3cedfc54-b105-4652-a4e0-847b11576b58",
      "subnet_id" : "c1cfa53c-65d3-431e-8552-326bf310c7ad",
      "security_group_id" : "fc577a1a-f202-424a-977f-24faec3fdd55",
      "configuration_id" : "43570e0de32e40c5a15f831aa5ce4176pr07",
      "password" : "***",
      "backup_strategy" : {
        "start_time" : "08:00-09:00"
      },
      "availability_zone_mode" : "single",
      "slave_count" : 1,
      "enterprise_project_id" : 0,
      "restore_point" : {
        "source_instance_id" : "7033e7c3cf93438797d44ad7ae0a7d95in07",
        "restore_time" : 1673852043000,
        "type" : "timestamp"
      }
    }

响应示例

状态码: 201

Success.

  • 创建按需实例。

    {
      "instance" : {
        "id" : "5eebbb4c0f9f4a99b42ed1b6334569aain07",
        "name" : "gaussdb-mysql-instance1",
        "status" : "BUILD",
        "region" : "br-iaas-odin1",
        "charge_info" : {
          "charge_mode" : "postPaid"
        },
        "datastore" : {
          "type" : "gaussdb-mysql",
          "version" : "8.0",
          "kernel_version" : "2.0.28.18"
        },
        "mode" : "Cluster",
        "port" : 3306,
        "enterprise_project_id" : 0,
        "flavor_ref" : "gaussdb.mysql.xlarge.arm.4",
        "vpc_id" : "3cedfc54-b105-4652-a4e0-847b11576b58",
        "subnet_id" : "c1cfa53c-65d3-431e-8552-326bf310c7ad",
        "security_group_id" : "fc577a1a-f202-424a-977f-24faec3fdd55",
        "configuration_id" : "43570e0de32e40c5a15f831aa5ce4176pr07",
        "backup_strategy" : {
          "start_time" : "08:00-09:00",
          "keep_days" : 7
        },
        "availability_zone_mode" : "single"
      },
      "job_id" : "dff1d289-4d03-4942-8b9f-463ea07c000d"
    }
  • 创建周期为一个月的包年/包月实例。

    {
      "instance" : {
        "id" : "945419c2208e4a5d828b8dddc00223e1in07",
        "name" : "gaussdb-mysql-instance4",
        "status" : "BUILD",
        "region" : "br-iaas-odin1",
        "charge_info" : {
          "charge_mode" : "prePaid",
          "period_type" : "month",
          "period_num" : 1,
          "is_auto_renew" : false,
          "is_auto_pay" : true
        },
        "volume" : {
          "size" : 10
        },
        "datastore" : {
          "type" : "gaussdb-mysql",
          "version" : "8.0",
          "kernel_version" : "2.0.28.18"
        },
        "mode" : "Cluster",
        "port" : 3306,
        "enterprise_project_id" : 0,
        "flavor_ref" : "gaussdb.mysql.xlarge.arm.4",
        "vpc_id" : "3cedfc54-b105-4652-a4e0-847b11576b58",
        "subnet_id" : "c1cfa53c-65d3-431e-8552-326bf310c7ad",
        "security_group_id" : "fc577a1a-f202-424a-977f-24faec3fdd55",
        "configuration_id" : "43570e0de32e40c5a15f831aa5ce4176pr07",
        "backup_strategy" : {
          "start_time" : "08:00-09:00",
          "keep_days" : 7
        },
        "availability_zone_mode" : "single"
      },
      "order_id" : "CS2308241236EEXVF"
    }

SDK代码示例

SDK代码示例如下。

Java

  • 创建计费模式为按需计费,自动备份开始时间是08:00-09:00的实例。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    package com.huaweicloud.sdk.test;
    
    import com.huaweicloud.sdk.core.auth.ICredential;
    import com.huaweicloud.sdk.core.auth.BasicCredentials;
    import com.huaweicloud.sdk.core.exception.ConnectionException;
    import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
    import com.huaweicloud.sdk.core.exception.ServiceResponseException;
    import com.huaweicloud.sdk.gaussdb.v3.region.GaussDBRegion;
    import com.huaweicloud.sdk.gaussdb.v3.*;
    import com.huaweicloud.sdk.gaussdb.v3.model.*;
    
    
    public class CreateGaussMySqlInstanceSolution {
    
        public static void main(String[] args) {
            // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
            // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
            String ak = System.getenv("CLOUD_SDK_AK");
            String sk = System.getenv("CLOUD_SDK_SK");
            String projectId = "{project_id}";
    
            ICredential auth = new BasicCredentials()
                    .withProjectId(projectId)
                    .withAk(ak)
                    .withSk(sk);
    
            GaussDBClient client = GaussDBClient.newBuilder()
                    .withCredential(auth)
                    .withRegion(GaussDBRegion.valueOf("<YOUR REGION>"))
                    .build();
            CreateGaussMySqlInstanceRequest request = new CreateGaussMySqlInstanceRequest();
            MysqlInstanceRequest body = new MysqlInstanceRequest();
            MysqlBackupStrategy backupStrategybody = new MysqlBackupStrategy();
            backupStrategybody.withStartTime("08:00-09:00");
            MysqlDatastoreInReq datastorebody = new MysqlDatastoreInReq();
            datastorebody.withType("gaussdb-mysql")
                .withVersion("8.0");
            MysqlChargeInfo chargeInfobody = new MysqlChargeInfo();
            chargeInfobody.withChargeMode(MysqlChargeInfo.ChargeModeEnum.fromValue("postPaid"));
            body.withEnterpriseProjectId("0");
            body.withSlaveCount(1);
            body.withAvailabilityZoneMode("single");
            body.withBackupStrategy(backupStrategybody);
            body.withPassword("***");
            body.withConfigurationId("43570e0de32e40c5a15f831aa5ce4176pr07");
            body.withSecurityGroupId("fc577a1a-f202-424a-977f-24faec3fdd55");
            body.withSubnetId("c1cfa53c-65d3-431e-8552-326bf310c7ad");
            body.withVpcId("3cedfc54-b105-4652-a4e0-847b11576b58");
            body.withFlavorRef("gaussdb.mysql.xlarge.arm.4");
            body.withMode("Cluster");
            body.withDatastore(datastorebody);
            body.withName("gaussdb-mysql-instance1");
            body.withRegion("br-iaas-odin1");
            body.withChargeInfo(chargeInfobody);
            request.withBody(body);
            try {
                CreateGaussMySqlInstanceResponse response = client.createGaussMySqlInstance(request);
                System.out.println(response.toString());
            } catch (ConnectionException e) {
                e.printStackTrace();
            } catch (RequestTimeoutException e) {
                e.printStackTrace();
            } catch (ServiceResponseException e) {
                e.printStackTrace();
                System.out.println(e.getHttpStatusCode());
                System.out.println(e.getRequestId());
                System.out.println(e.getErrorCode());
                System.out.println(e.getErrorMsg());
            }
        }
    }
    
  • 将备份文件恢复到按需计费的新实例。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    package com.huaweicloud.sdk.test;
    
    import com.huaweicloud.sdk.core.auth.ICredential;
    import com.huaweicloud.sdk.core.auth.BasicCredentials;
    import com.huaweicloud.sdk.core.exception.ConnectionException;
    import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
    import com.huaweicloud.sdk.core.exception.ServiceResponseException;
    import com.huaweicloud.sdk.gaussdb.v3.region.GaussDBRegion;
    import com.huaweicloud.sdk.gaussdb.v3.*;
    import com.huaweicloud.sdk.gaussdb.v3.model.*;
    
    
    public class CreateGaussMySqlInstanceSolution {
    
        public static void main(String[] args) {
            // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
            // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
            String ak = System.getenv("CLOUD_SDK_AK");
            String sk = System.getenv("CLOUD_SDK_SK");
            String projectId = "{project_id}";
    
            ICredential auth = new BasicCredentials()
                    .withProjectId(projectId)
                    .withAk(ak)
                    .withSk(sk);
    
            GaussDBClient client = GaussDBClient.newBuilder()
                    .withCredential(auth)
                    .withRegion(GaussDBRegion.valueOf("<YOUR REGION>"))
                    .build();
            CreateGaussMySqlInstanceRequest request = new CreateGaussMySqlInstanceRequest();
            MysqlInstanceRequest body = new MysqlInstanceRequest();
            MysqlRestorePoint restorePointbody = new MysqlRestorePoint();
            restorePointbody.withSourceInstanceId("7033e7c3cf93438797d44ad7ae0a7d95in07")
                .withBackupId("7ffbf305376b4cbea0ae491257b6aaf9br07")
                .withType("backup");
            MysqlBackupStrategy backupStrategybody = new MysqlBackupStrategy();
            backupStrategybody.withStartTime("08:00-09:00");
            MysqlDatastoreInReq datastorebody = new MysqlDatastoreInReq();
            datastorebody.withType("gaussdb-mysql")
                .withVersion("8.0");
            MysqlChargeInfo chargeInfobody = new MysqlChargeInfo();
            chargeInfobody.withChargeMode(MysqlChargeInfo.ChargeModeEnum.fromValue("postPaid"));
            body.withRestorePoint(restorePointbody);
            body.withEnterpriseProjectId("0");
            body.withSlaveCount(1);
            body.withAvailabilityZoneMode("single");
            body.withBackupStrategy(backupStrategybody);
            body.withPassword("***");
            body.withConfigurationId("43570e0de32e40c5a15f831aa5ce4176pr07");
            body.withSecurityGroupId("fc577a1a-f202-424a-977f-24faec3fdd55");
            body.withSubnetId("c1cfa53c-65d3-431e-8552-326bf310c7ad");
            body.withVpcId("3cedfc54-b105-4652-a4e0-847b11576b58");
            body.withFlavorRef("gaussdb.mysql.xlarge.arm.4");
            body.withMode("Cluster");
            body.withDatastore(datastorebody);
            body.withName("gaussdb-mysql-instance2");
            body.withRegion("br-iaas-odin1");
            body.withChargeInfo(chargeInfobody);
            request.withBody(body);
            try {
                CreateGaussMySqlInstanceResponse response = client.createGaussMySqlInstance(request);
                System.out.println(response.toString());
            } catch (ConnectionException e) {
                e.printStackTrace();
            } catch (RequestTimeoutException e) {
                e.printStackTrace();
            } catch (ServiceResponseException e) {
                e.printStackTrace();
                System.out.println(e.getHttpStatusCode());
                System.out.println(e.getRequestId());
                System.out.println(e.getErrorCode());
                System.out.println(e.getErrorMsg());
            }
        }
    }
    
  • 按时间点恢复到按需计费的新实例。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    package com.huaweicloud.sdk.test;
    
    import com.huaweicloud.sdk.core.auth.ICredential;
    import com.huaweicloud.sdk.core.auth.BasicCredentials;
    import com.huaweicloud.sdk.core.exception.ConnectionException;
    import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
    import com.huaweicloud.sdk.core.exception.ServiceResponseException;
    import com.huaweicloud.sdk.gaussdb.v3.region.GaussDBRegion;
    import com.huaweicloud.sdk.gaussdb.v3.*;
    import com.huaweicloud.sdk.gaussdb.v3.model.*;
    
    
    public class CreateGaussMySqlInstanceSolution {
    
        public static void main(String[] args) {
            // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
            // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
            String ak = System.getenv("CLOUD_SDK_AK");
            String sk = System.getenv("CLOUD_SDK_SK");
            String projectId = "{project_id}";
    
            ICredential auth = new BasicCredentials()
                    .withProjectId(projectId)
                    .withAk(ak)
                    .withSk(sk);
    
            GaussDBClient client = GaussDBClient.newBuilder()
                    .withCredential(auth)
                    .withRegion(GaussDBRegion.valueOf("<YOUR REGION>"))
                    .build();
            CreateGaussMySqlInstanceRequest request = new CreateGaussMySqlInstanceRequest();
            MysqlInstanceRequest body = new MysqlInstanceRequest();
            MysqlRestorePoint restorePointbody = new MysqlRestorePoint();
            restorePointbody.withRestoreTime(1673852043000L)
                .withSourceInstanceId("7033e7c3cf93438797d44ad7ae0a7d95in07")
                .withType("timestamp");
            MysqlBackupStrategy backupStrategybody = new MysqlBackupStrategy();
            backupStrategybody.withStartTime("08:00-09:00");
            MysqlDatastoreInReq datastorebody = new MysqlDatastoreInReq();
            datastorebody.withType("gaussdb-mysql")
                .withVersion("8.0");
            MysqlChargeInfo chargeInfobody = new MysqlChargeInfo();
            chargeInfobody.withChargeMode(MysqlChargeInfo.ChargeModeEnum.fromValue("postPaid"));
            body.withRestorePoint(restorePointbody);
            body.withEnterpriseProjectId("0");
            body.withSlaveCount(1);
            body.withAvailabilityZoneMode("single");
            body.withBackupStrategy(backupStrategybody);
            body.withPassword("***");
            body.withConfigurationId("43570e0de32e40c5a15f831aa5ce4176pr07");
            body.withSecurityGroupId("fc577a1a-f202-424a-977f-24faec3fdd55");
            body.withSubnetId("c1cfa53c-65d3-431e-8552-326bf310c7ad");
            body.withVpcId("3cedfc54-b105-4652-a4e0-847b11576b58");
            body.withFlavorRef("gaussdb.mysql.xlarge.arm.4");
            body.withMode("Cluster");
            body.withDatastore(datastorebody);
            body.withName("gaussdb-mysql-instance3");
            body.withRegion("br-iaas-odin1");
            body.withChargeInfo(chargeInfobody);
            request.withBody(body);
            try {
                CreateGaussMySqlInstanceResponse response = client.createGaussMySqlInstance(request);
                System.out.println(response.toString());
            } catch (ConnectionException e) {
                e.printStackTrace();
            } catch (RequestTimeoutException e) {
                e.printStackTrace();
            } catch (ServiceResponseException e) {
                e.printStackTrace();
                System.out.println(e.getHttpStatusCode());
                System.out.println(e.getRequestId());
                System.out.println(e.getErrorCode());
                System.out.println(e.getErrorMsg());
            }
        }
    }
    
  • 创建周期为一个月的包年/包月实例。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    package com.huaweicloud.sdk.test;
    
    import com.huaweicloud.sdk.core.auth.ICredential;
    import com.huaweicloud.sdk.core.auth.BasicCredentials;
    import com.huaweicloud.sdk.core.exception.ConnectionException;
    import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
    import com.huaweicloud.sdk.core.exception.ServiceResponseException;
    import com.huaweicloud.sdk.gaussdb.v3.region.GaussDBRegion;
    import com.huaweicloud.sdk.gaussdb.v3.*;
    import com.huaweicloud.sdk.gaussdb.v3.model.*;
    
    
    public class CreateGaussMySqlInstanceSolution {
    
        public static void main(String[] args) {
            // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
            // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
            String ak = System.getenv("CLOUD_SDK_AK");
            String sk = System.getenv("CLOUD_SDK_SK");
            String projectId = "{project_id}";
    
            ICredential auth = new BasicCredentials()
                    .withProjectId(projectId)
                    .withAk(ak)
                    .withSk(sk);
    
            GaussDBClient client = GaussDBClient.newBuilder()
                    .withCredential(auth)
                    .withRegion(GaussDBRegion.valueOf("<YOUR REGION>"))
                    .build();
            CreateGaussMySqlInstanceRequest request = new CreateGaussMySqlInstanceRequest();
            MysqlInstanceRequest body = new MysqlInstanceRequest();
            MysqlRestorePoint restorePointbody = new MysqlRestorePoint();
            restorePointbody.withRestoreTime(1673852043000L)
                .withSourceInstanceId("7033e7c3cf93438797d44ad7ae0a7d95in07")
                .withType("timestamp");
            MysqlVolume volumebody = new MysqlVolume();
            volumebody.withSize("10");
            MysqlBackupStrategy backupStrategybody = new MysqlBackupStrategy();
            backupStrategybody.withStartTime("08:00-09:00");
            MysqlDatastoreInReq datastorebody = new MysqlDatastoreInReq();
            datastorebody.withType("gaussdb-mysql")
                .withVersion("8.0");
            MysqlChargeInfo chargeInfobody = new MysqlChargeInfo();
            chargeInfobody.withChargeMode(MysqlChargeInfo.ChargeModeEnum.fromValue("prePaid"))
                .withPeriodType(MysqlChargeInfo.PeriodTypeEnum.fromValue("month"))
                .withPeriodNum(1)
                .withIsAutoRenew("false")
                .withIsAutoPay("true");
            body.withRestorePoint(restorePointbody);
            body.withEnterpriseProjectId("0");
            body.withVolume(volumebody);
            body.withSlaveCount(1);
            body.withAvailabilityZoneMode("single");
            body.withBackupStrategy(backupStrategybody);
            body.withPassword("***");
            body.withConfigurationId("43570e0de32e40c5a15f831aa5ce4176pr07");
            body.withSecurityGroupId("fc577a1a-f202-424a-977f-24faec3fdd55");
            body.withSubnetId("c1cfa53c-65d3-431e-8552-326bf310c7ad");
            body.withVpcId("3cedfc54-b105-4652-a4e0-847b11576b58");
            body.withFlavorRef("gaussdb.mysql.xlarge.arm.4");
            body.withMode("Cluster");
            body.withDatastore(datastorebody);
            body.withName("gaussdb-mysql-instance4");
            body.withRegion("br-iaas-odin1");
            body.withChargeInfo(chargeInfobody);
            request.withBody(body);
            try {
                CreateGaussMySqlInstanceResponse response = client.createGaussMySqlInstance(request);
                System.out.println(response.toString());
            } catch (ConnectionException e) {
                e.printStackTrace();
            } catch (RequestTimeoutException e) {
                e.printStackTrace();
            } catch (ServiceResponseException e) {
                e.printStackTrace();
                System.out.println(e.getHttpStatusCode());
                System.out.println(e.getRequestId());
                System.out.println(e.getErrorCode());
                System.out.println(e.getErrorMsg());
            }
        }
    }
    

Python

  • 创建计费模式为按需计费,自动备份开始时间是08:00-09:00的实例。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    # coding: utf-8
    
    import os
    from huaweicloudsdkcore.auth.credentials import BasicCredentials
    from huaweicloudsdkgaussdb.v3.region.gaussdb_region import GaussDBRegion
    from huaweicloudsdkcore.exceptions import exceptions
    from huaweicloudsdkgaussdb.v3 import *
    
    if __name__ == "__main__":
        # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak = os.environ["CLOUD_SDK_AK"]
        sk = os.environ["CLOUD_SDK_SK"]
        projectId = "{project_id}"
    
        credentials = BasicCredentials(ak, sk, projectId)
    
        client = GaussDBClient.new_builder() \
            .with_credentials(credentials) \
            .with_region(GaussDBRegion.value_of("<YOUR REGION>")) \
            .build()
    
        try:
            request = CreateGaussMySqlInstanceRequest()
            backupStrategybody = MysqlBackupStrategy(
                start_time="08:00-09:00"
            )
            datastorebody = MysqlDatastoreInReq(
                type="gaussdb-mysql",
                version="8.0"
            )
            chargeInfobody = MysqlChargeInfo(
                charge_mode="postPaid"
            )
            request.body = MysqlInstanceRequest(
                enterprise_project_id="0",
                slave_count=1,
                availability_zone_mode="single",
                backup_strategy=backupStrategybody,
                password="***",
                configuration_id="43570e0de32e40c5a15f831aa5ce4176pr07",
                security_group_id="fc577a1a-f202-424a-977f-24faec3fdd55",
                subnet_id="c1cfa53c-65d3-431e-8552-326bf310c7ad",
                vpc_id="3cedfc54-b105-4652-a4e0-847b11576b58",
                flavor_ref="gaussdb.mysql.xlarge.arm.4",
                mode="Cluster",
                datastore=datastorebody,
                name="gaussdb-mysql-instance1",
                region="br-iaas-odin1",
                charge_info=chargeInfobody
            )
            response = client.create_gauss_my_sql_instance(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • 将备份文件恢复到按需计费的新实例。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    # coding: utf-8
    
    import os
    from huaweicloudsdkcore.auth.credentials import BasicCredentials
    from huaweicloudsdkgaussdb.v3.region.gaussdb_region import GaussDBRegion
    from huaweicloudsdkcore.exceptions import exceptions
    from huaweicloudsdkgaussdb.v3 import *
    
    if __name__ == "__main__":
        # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak = os.environ["CLOUD_SDK_AK"]
        sk = os.environ["CLOUD_SDK_SK"]
        projectId = "{project_id}"
    
        credentials = BasicCredentials(ak, sk, projectId)
    
        client = GaussDBClient.new_builder() \
            .with_credentials(credentials) \
            .with_region(GaussDBRegion.value_of("<YOUR REGION>")) \
            .build()
    
        try:
            request = CreateGaussMySqlInstanceRequest()
            restorePointbody = MysqlRestorePoint(
                source_instance_id="7033e7c3cf93438797d44ad7ae0a7d95in07",
                backup_id="7ffbf305376b4cbea0ae491257b6aaf9br07",
                type="backup"
            )
            backupStrategybody = MysqlBackupStrategy(
                start_time="08:00-09:00"
            )
            datastorebody = MysqlDatastoreInReq(
                type="gaussdb-mysql",
                version="8.0"
            )
            chargeInfobody = MysqlChargeInfo(
                charge_mode="postPaid"
            )
            request.body = MysqlInstanceRequest(
                restore_point=restorePointbody,
                enterprise_project_id="0",
                slave_count=1,
                availability_zone_mode="single",
                backup_strategy=backupStrategybody,
                password="***",
                configuration_id="43570e0de32e40c5a15f831aa5ce4176pr07",
                security_group_id="fc577a1a-f202-424a-977f-24faec3fdd55",
                subnet_id="c1cfa53c-65d3-431e-8552-326bf310c7ad",
                vpc_id="3cedfc54-b105-4652-a4e0-847b11576b58",
                flavor_ref="gaussdb.mysql.xlarge.arm.4",
                mode="Cluster",
                datastore=datastorebody,
                name="gaussdb-mysql-instance2",
                region="br-iaas-odin1",
                charge_info=chargeInfobody
            )
            response = client.create_gauss_my_sql_instance(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • 按时间点恢复到按需计费的新实例。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    # coding: utf-8
    
    import os
    from huaweicloudsdkcore.auth.credentials import BasicCredentials
    from huaweicloudsdkgaussdb.v3.region.gaussdb_region import GaussDBRegion
    from huaweicloudsdkcore.exceptions import exceptions
    from huaweicloudsdkgaussdb.v3 import *
    
    if __name__ == "__main__":
        # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak = os.environ["CLOUD_SDK_AK"]
        sk = os.environ["CLOUD_SDK_SK"]
        projectId = "{project_id}"
    
        credentials = BasicCredentials(ak, sk, projectId)
    
        client = GaussDBClient.new_builder() \
            .with_credentials(credentials) \
            .with_region(GaussDBRegion.value_of("<YOUR REGION>")) \
            .build()
    
        try:
            request = CreateGaussMySqlInstanceRequest()
            restorePointbody = MysqlRestorePoint(
                restore_time=1673852043000,
                source_instance_id="7033e7c3cf93438797d44ad7ae0a7d95in07",
                type="timestamp"
            )
            backupStrategybody = MysqlBackupStrategy(
                start_time="08:00-09:00"
            )
            datastorebody = MysqlDatastoreInReq(
                type="gaussdb-mysql",
                version="8.0"
            )
            chargeInfobody = MysqlChargeInfo(
                charge_mode="postPaid"
            )
            request.body = MysqlInstanceRequest(
                restore_point=restorePointbody,
                enterprise_project_id="0",
                slave_count=1,
                availability_zone_mode="single",
                backup_strategy=backupStrategybody,
                password="***",
                configuration_id="43570e0de32e40c5a15f831aa5ce4176pr07",
                security_group_id="fc577a1a-f202-424a-977f-24faec3fdd55",
                subnet_id="c1cfa53c-65d3-431e-8552-326bf310c7ad",
                vpc_id="3cedfc54-b105-4652-a4e0-847b11576b58",
                flavor_ref="gaussdb.mysql.xlarge.arm.4",
                mode="Cluster",
                datastore=datastorebody,
                name="gaussdb-mysql-instance3",
                region="br-iaas-odin1",
                charge_info=chargeInfobody
            )
            response = client.create_gauss_my_sql_instance(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • 创建周期为一个月的包年/包月实例。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    # coding: utf-8
    
    import os
    from huaweicloudsdkcore.auth.credentials import BasicCredentials
    from huaweicloudsdkgaussdb.v3.region.gaussdb_region import GaussDBRegion
    from huaweicloudsdkcore.exceptions import exceptions
    from huaweicloudsdkgaussdb.v3 import *
    
    if __name__ == "__main__":
        # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak = os.environ["CLOUD_SDK_AK"]
        sk = os.environ["CLOUD_SDK_SK"]
        projectId = "{project_id}"
    
        credentials = BasicCredentials(ak, sk, projectId)
    
        client = GaussDBClient.new_builder() \
            .with_credentials(credentials) \
            .with_region(GaussDBRegion.value_of("<YOUR REGION>")) \
            .build()
    
        try:
            request = CreateGaussMySqlInstanceRequest()
            restorePointbody = MysqlRestorePoint(
                restore_time=1673852043000,
                source_instance_id="7033e7c3cf93438797d44ad7ae0a7d95in07",
                type="timestamp"
            )
            volumebody = MysqlVolume(
                size="10"
            )
            backupStrategybody = MysqlBackupStrategy(
                start_time="08:00-09:00"
            )
            datastorebody = MysqlDatastoreInReq(
                type="gaussdb-mysql",
                version="8.0"
            )
            chargeInfobody = MysqlChargeInfo(
                charge_mode="prePaid",
                period_type="month",
                period_num=1,
                is_auto_renew="false",
                is_auto_pay="true"
            )
            request.body = MysqlInstanceRequest(
                restore_point=restorePointbody,
                enterprise_project_id="0",
                volume=volumebody,
                slave_count=1,
                availability_zone_mode="single",
                backup_strategy=backupStrategybody,
                password="***",
                configuration_id="43570e0de32e40c5a15f831aa5ce4176pr07",
                security_group_id="fc577a1a-f202-424a-977f-24faec3fdd55",
                subnet_id="c1cfa53c-65d3-431e-8552-326bf310c7ad",
                vpc_id="3cedfc54-b105-4652-a4e0-847b11576b58",
                flavor_ref="gaussdb.mysql.xlarge.arm.4",
                mode="Cluster",
                datastore=datastorebody,
                name="gaussdb-mysql-instance4",
                region="br-iaas-odin1",
                charge_info=chargeInfobody
            )
            response = client.create_gauss_my_sql_instance(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    

Go

  • 创建计费模式为按需计费,自动备份开始时间是08:00-09:00的实例。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    package main
    
    import (
    	"fmt"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
        gaussdb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/gaussdb/v3"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/gaussdb/v3/model"
        region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/gaussdb/v3/region"
    )
    
    func main() {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak := os.Getenv("CLOUD_SDK_AK")
        sk := os.Getenv("CLOUD_SDK_SK")
        projectId := "{project_id}"
    
        auth := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            Build()
    
        client := gaussdb.NewGaussDBClient(
            gaussdb.GaussDBClientBuilder().
                WithRegion(region.ValueOf("<YOUR REGION>")).
                WithCredential(auth).
                Build())
    
        request := &model.CreateGaussMySqlInstanceRequest{}
    	backupStrategybody := &model.MysqlBackupStrategy{
    		StartTime: "08:00-09:00",
    	}
    	datastorebody := &model.MysqlDatastoreInReq{
    		Type: "gaussdb-mysql",
    		Version: "8.0",
    	}
    	chargeInfobody := &model.MysqlChargeInfo{
    		ChargeMode: model.GetMysqlChargeInfoChargeModeEnum().POST_PAID,
    	}
    	enterpriseProjectIdMysqlInstanceRequest:= "0"
    	configurationIdMysqlInstanceRequest:= "43570e0de32e40c5a15f831aa5ce4176pr07"
    	securityGroupIdMysqlInstanceRequest:= "fc577a1a-f202-424a-977f-24faec3fdd55"
    	request.Body = &model.MysqlInstanceRequest{
    		EnterpriseProjectId: &enterpriseProjectIdMysqlInstanceRequest,
    		SlaveCount: int32(1),
    		AvailabilityZoneMode: "single",
    		BackupStrategy: backupStrategybody,
    		Password: "***",
    		ConfigurationId: &configurationIdMysqlInstanceRequest,
    		SecurityGroupId: &securityGroupIdMysqlInstanceRequest,
    		SubnetId: "c1cfa53c-65d3-431e-8552-326bf310c7ad",
    		VpcId: "3cedfc54-b105-4652-a4e0-847b11576b58",
    		FlavorRef: "gaussdb.mysql.xlarge.arm.4",
    		Mode: "Cluster",
    		Datastore: datastorebody,
    		Name: "gaussdb-mysql-instance1",
    		Region: "br-iaas-odin1",
    		ChargeInfo: chargeInfobody,
    	}
    	response, err := client.CreateGaussMySqlInstance(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • 将备份文件恢复到按需计费的新实例。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    package main
    
    import (
    	"fmt"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
        gaussdb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/gaussdb/v3"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/gaussdb/v3/model"
        region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/gaussdb/v3/region"
    )
    
    func main() {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak := os.Getenv("CLOUD_SDK_AK")
        sk := os.Getenv("CLOUD_SDK_SK")
        projectId := "{project_id}"
    
        auth := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            Build()
    
        client := gaussdb.NewGaussDBClient(
            gaussdb.GaussDBClientBuilder().
                WithRegion(region.ValueOf("<YOUR REGION>")).
                WithCredential(auth).
                Build())
    
        request := &model.CreateGaussMySqlInstanceRequest{}
    	backupIdRestorePoint:= "7ffbf305376b4cbea0ae491257b6aaf9br07"
    	typeRestorePoint:= "backup"
    	restorePointbody := &model.MysqlRestorePoint{
    		SourceInstanceId: "7033e7c3cf93438797d44ad7ae0a7d95in07",
    		BackupId: &backupIdRestorePoint,
    		Type: &typeRestorePoint,
    	}
    	backupStrategybody := &model.MysqlBackupStrategy{
    		StartTime: "08:00-09:00",
    	}
    	datastorebody := &model.MysqlDatastoreInReq{
    		Type: "gaussdb-mysql",
    		Version: "8.0",
    	}
    	chargeInfobody := &model.MysqlChargeInfo{
    		ChargeMode: model.GetMysqlChargeInfoChargeModeEnum().POST_PAID,
    	}
    	enterpriseProjectIdMysqlInstanceRequest:= "0"
    	configurationIdMysqlInstanceRequest:= "43570e0de32e40c5a15f831aa5ce4176pr07"
    	securityGroupIdMysqlInstanceRequest:= "fc577a1a-f202-424a-977f-24faec3fdd55"
    	request.Body = &model.MysqlInstanceRequest{
    		RestorePoint: restorePointbody,
    		EnterpriseProjectId: &enterpriseProjectIdMysqlInstanceRequest,
    		SlaveCount: int32(1),
    		AvailabilityZoneMode: "single",
    		BackupStrategy: backupStrategybody,
    		Password: "***",
    		ConfigurationId: &configurationIdMysqlInstanceRequest,
    		SecurityGroupId: &securityGroupIdMysqlInstanceRequest,
    		SubnetId: "c1cfa53c-65d3-431e-8552-326bf310c7ad",
    		VpcId: "3cedfc54-b105-4652-a4e0-847b11576b58",
    		FlavorRef: "gaussdb.mysql.xlarge.arm.4",
    		Mode: "Cluster",
    		Datastore: datastorebody,
    		Name: "gaussdb-mysql-instance2",
    		Region: "br-iaas-odin1",
    		ChargeInfo: chargeInfobody,
    	}
    	response, err := client.CreateGaussMySqlInstance(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • 按时间点恢复到按需计费的新实例。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    package main
    
    import (
    	"fmt"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
        gaussdb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/gaussdb/v3"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/gaussdb/v3/model"
        region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/gaussdb/v3/region"
    )
    
    func main() {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak := os.Getenv("CLOUD_SDK_AK")
        sk := os.Getenv("CLOUD_SDK_SK")
        projectId := "{project_id}"
    
        auth := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            Build()
    
        client := gaussdb.NewGaussDBClient(
            gaussdb.GaussDBClientBuilder().
                WithRegion(region.ValueOf("<YOUR REGION>")).
                WithCredential(auth).
                Build())
    
        request := &model.CreateGaussMySqlInstanceRequest{}
    	restoreTimeRestorePoint:= int64(1673852043000)
    	typeRestorePoint:= "timestamp"
    	restorePointbody := &model.MysqlRestorePoint{
    		RestoreTime: &restoreTimeRestorePoint,
    		SourceInstanceId: "7033e7c3cf93438797d44ad7ae0a7d95in07",
    		Type: &typeRestorePoint,
    	}
    	backupStrategybody := &model.MysqlBackupStrategy{
    		StartTime: "08:00-09:00",
    	}
    	datastorebody := &model.MysqlDatastoreInReq{
    		Type: "gaussdb-mysql",
    		Version: "8.0",
    	}
    	chargeInfobody := &model.MysqlChargeInfo{
    		ChargeMode: model.GetMysqlChargeInfoChargeModeEnum().POST_PAID,
    	}
    	enterpriseProjectIdMysqlInstanceRequest:= "0"
    	configurationIdMysqlInstanceRequest:= "43570e0de32e40c5a15f831aa5ce4176pr07"
    	securityGroupIdMysqlInstanceRequest:= "fc577a1a-f202-424a-977f-24faec3fdd55"
    	request.Body = &model.MysqlInstanceRequest{
    		RestorePoint: restorePointbody,
    		EnterpriseProjectId: &enterpriseProjectIdMysqlInstanceRequest,
    		SlaveCount: int32(1),
    		AvailabilityZoneMode: "single",
    		BackupStrategy: backupStrategybody,
    		Password: "***",
    		ConfigurationId: &configurationIdMysqlInstanceRequest,
    		SecurityGroupId: &securityGroupIdMysqlInstanceRequest,
    		SubnetId: "c1cfa53c-65d3-431e-8552-326bf310c7ad",
    		VpcId: "3cedfc54-b105-4652-a4e0-847b11576b58",
    		FlavorRef: "gaussdb.mysql.xlarge.arm.4",
    		Mode: "Cluster",
    		Datastore: datastorebody,
    		Name: "gaussdb-mysql-instance3",
    		Region: "br-iaas-odin1",
    		ChargeInfo: chargeInfobody,
    	}
    	response, err := client.CreateGaussMySqlInstance(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • 创建周期为一个月的包年/包月实例。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    package main
    
    import (
    	"fmt"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
        gaussdb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/gaussdb/v3"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/gaussdb/v3/model"
        region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/gaussdb/v3/region"
    )
    
    func main() {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak := os.Getenv("CLOUD_SDK_AK")
        sk := os.Getenv("CLOUD_SDK_SK")
        projectId := "{project_id}"
    
        auth := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            Build()
    
        client := gaussdb.NewGaussDBClient(
            gaussdb.GaussDBClientBuilder().
                WithRegion(region.ValueOf("<YOUR REGION>")).
                WithCredential(auth).
                Build())
    
        request := &model.CreateGaussMySqlInstanceRequest{}
    	restoreTimeRestorePoint:= int64(1673852043000)
    	typeRestorePoint:= "timestamp"
    	restorePointbody := &model.MysqlRestorePoint{
    		RestoreTime: &restoreTimeRestorePoint,
    		SourceInstanceId: "7033e7c3cf93438797d44ad7ae0a7d95in07",
    		Type: &typeRestorePoint,
    	}
    	volumebody := &model.MysqlVolume{
    		Size: "10",
    	}
    	backupStrategybody := &model.MysqlBackupStrategy{
    		StartTime: "08:00-09:00",
    	}
    	datastorebody := &model.MysqlDatastoreInReq{
    		Type: "gaussdb-mysql",
    		Version: "8.0",
    	}
    	periodTypeChargeInfo:= model.GetMysqlChargeInfoPeriodTypeEnum().MONTH
    	periodNumChargeInfo:= int32(1)
    	isAutoRenewChargeInfo:= "false"
    	isAutoPayChargeInfo:= "true"
    	chargeInfobody := &model.MysqlChargeInfo{
    		ChargeMode: model.GetMysqlChargeInfoChargeModeEnum().PRE_PAID,
    		PeriodType: &periodTypeChargeInfo,
    		PeriodNum: &periodNumChargeInfo,
    		IsAutoRenew: &isAutoRenewChargeInfo,
    		IsAutoPay: &isAutoPayChargeInfo,
    	}
    	enterpriseProjectIdMysqlInstanceRequest:= "0"
    	configurationIdMysqlInstanceRequest:= "43570e0de32e40c5a15f831aa5ce4176pr07"
    	securityGroupIdMysqlInstanceRequest:= "fc577a1a-f202-424a-977f-24faec3fdd55"
    	request.Body = &model.MysqlInstanceRequest{
    		RestorePoint: restorePointbody,
    		EnterpriseProjectId: &enterpriseProjectIdMysqlInstanceRequest,
    		Volume: volumebody,
    		SlaveCount: int32(1),
    		AvailabilityZoneMode: "single",
    		BackupStrategy: backupStrategybody,
    		Password: "***",
    		ConfigurationId: &configurationIdMysqlInstanceRequest,
    		SecurityGroupId: &securityGroupIdMysqlInstanceRequest,
    		SubnetId: "c1cfa53c-65d3-431e-8552-326bf310c7ad",
    		VpcId: "3cedfc54-b105-4652-a4e0-847b11576b58",
    		FlavorRef: "gaussdb.mysql.xlarge.arm.4",
    		Mode: "Cluster",
    		Datastore: datastorebody,
    		Name: "gaussdb-mysql-instance4",
    		Region: "br-iaas-odin1",
    		ChargeInfo: chargeInfobody,
    	}
    	response, err := client.CreateGaussMySqlInstance(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    

更多

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

201

Success.

400

Client error.

500

Server error.

错误码

请参见错误码

提示

您即将访问非华为云网站,请注意账号财产安全

文档反馈

文档反馈

意见反馈

0/500

标记内容

同时提交标记内容