Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Creating a Connection

Function

This API is used to create a single connection. The connection database can be an on-premises database or an RDS DB instance. Currently, the supported DB engines include MySQL, PostgreSQL, Oracle, and MongoDB.

URI

POST /v5/{project_id}/connections

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID of a tenant in a region.

For details about how to obtain the project ID, see Obtaining a Project ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

MIME type of the request body. Use the default value application/json. For APIs used to upload objects or images, the value varies depending on the flow type.

X-Auth-Token

Yes

String

User token obtained from IAM. It is a response to the API for obtaining a user token. This API is the only one that does not require authentication. The token is the value of X-Subject-Token in the response header.

X-Language

No

String

Request language type.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

name

Yes

String

Name of a connection. The connection name can be 4 to 50 characters in length. It is case-insensitive and can contain only letters, digits, hyphens (-), and underscores (_).

db_type

Yes

String

Connection type. The values are as follows:

  • mysql
  • postgresql
  • mongodb
  • oracle

config

No

ConnectionConfig object

Connection configuration item. The configuration item varies with the connection type.

description

No

String

Description of the connection. The description contains a maximum of 255 characters.

endpoint

Yes

BaseEndpoint object

Basic information about the database connection.

vpc

No

CloudVpcInfo object

Information about the VPC, subnet, and security group where a DB instance resides.

ssl

No

EndpointSslConfig object

Information of the database SSL certificate.

cloud

No

CloudBaseInfo object

Region and project where a DB instance is located.

enterprise_project_id

No

String

Enterprise project ID.

Table 4 ConnectionConfig

Parameter

Mandatory

Type

Description

driver_name

No

String

Driver name.

Table 5 BaseEndpoint

Parameter

Mandatory

Type

Description

id

No

String

Database information ID.

endpoint_name

Yes

String

Database scenario type. Values:

  • oracle: On-premises Oracle database.
  • ecs_oracle: Oracle database built on Huawei Cloud ECSs.
  • cloud_gaussdbv5: Huawei Cloud distributed GaussDB database.
  • mysql: MySQL database on other clouds or on-premises MySQL database.
  • ecs_mysql: MySQL database built on Huawei Cloud ECSs.
  • cloud_mysql: Huawei Cloud RDS for MySQL database.
  • redis: On-premises Redis database.
  • ecs_redis: Redis database built on Huawei Cloud ECSs.
  • rediscluster: On-premises Redis Cluster database.
  • ecs_rediscluster: Redis Cluster database built on Huawei Cloud ECSs.
  • cloud_gaussdb_redis: Huawei Cloud GeminiDB Redis database.
  • postgresql: On-premises PostgreSQL database.
  • ecs_postgresql: PostgreSQL database built on Huawei Cloud ECSs.
  • cloud_postgresql: Huawei Cloud RDS for PostgreSQL database.
  • mongodb: On-premises MongoDB database.
  • ecs_mongodb: MongoDB database built on Huawei Cloud ECSs.
  • cloud_mongodb: Huawei Cloud DDS database.

ip

No

String

Database IP address. If an on-premises MongoDB database is used, use colons (:) to separate the database IP address and port number, and use commas (,) to separate multiple values. A maximum of three IP addresses or domain names can be entered. If a DDS instance is used, use colons (:) to separate the database IP address and port number, and use commas (,) to separate multiple values. If a Redis Cluster database is used, enter the IP addresses and port numbers of all shards in the source Redis Cluster database. Use colons (:) to separate a database IP address and port number. Use commas (,) to separate multiple values. You are advised to enter the IP address of the slave node of a cluster shard. Up to 32 IP addresses or domain names can be entered. Use commas (,) to separate multiple IP addresses or domain names. Example: MySQL: ip; MongoDB: ip:port,ip:port,ip:port; DDS: ip:port,ip:port; Cluster Redis: ip:port,ip:port

db_port

No

String

Database port.

The value is an integer ranging from 1 to 65535.

db_user

Yes

String

Database username.

db_password

Yes

String

Database password.

instance_id

No

String

ID of a Huawei Cloud DB instance.

instance_name

No

String

Name of a Huawei Cloud DB instance.

db_name

No

String

Database name. Example:

  • oracle: serviceName.orcl.

source_sharding

No

Array of BaseEndpoint objects

Information about the physical source database.

Table 6 CloudVpcInfo

Parameter

Mandatory

Type

Description

vpc_id

Yes

String

ID of the VPC where a DB instance is located. To obtain the ID, perform the following steps:

Method 1: Log in to the VPC console and view the VPC ID on the VPC details page.

Method 2: Query the VPC ID through the VPC API. For details, see "Querying VPCs".

subnet_id

Yes

String

ID of the subnet where a DB instance is located. To obtain the ID, perform the following steps:

Method 1: Log in to the VPC console and click the target subnet on the Subnets page to view the network ID on the displayed page.

Method 2: Query the subnet ID through the VPC API. For details, see "Querying Subnets".

security_group_id

No

String

ID of the security group where a DB instance is located. To obtain the ID, perform the following steps:

Method 1: Log in to the 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.

Method 2: Query the security group through the VPC API. For details, see "Querying Security Groups".

Table 7 EndpointSslConfig

Parameter

Mandatory

Type

Description

ssl_link

No

Boolean

Whether SSL is enabled. If SSL is enabled, the value of this parameter is true.

ssl_cert_name

No

String

SSL certificate name.

ssl_cert_key

No

String

SSL certificate content, which is encrypted using Base64.

ssl_cert_check_sum

No

String

The checksum value of an SSL certificate, which is used for backend verification. This parameter is mandatory for secure connection to a source database.

ssl_cert_password

No

String

SSL certificate password. This parameter is mandatory if the certificate file name extension is .p12.

Table 8 CloudBaseInfo

Parameter

Mandatory

Type

Description

region

Yes

String

Region ID. This parameter is mandatory when DB Instance Type is set to ecs (database built on Huawei Cloud ECSs) or cloud (Huawei Clouddatabase). For details, see "Regions and Endpoints".

Note: If there are subprojects in a region, the region ID is the combination of regional project ID and subproject ID, which are combined using an underscore (_), for example, cn-north-4_abc.

project_id

Yes

String

Project ID of a tenant in a region. For details about how to obtain the project ID, see "Obtaining a Project ID".

az_code

No

String

Name of the AZ where the database is located.

Response Parameters

Status code: 200

Table 9 Response body parameters

Parameter

Type

Description

connection_id

String

Connection ID.

name

String

Name of a connection.

create_time

Long

Time when a connection is created, in timestamp format.

db_type

String

Connection type.

config

ConnectionConfig object

Configuration item of a connection.

endpoint

BaseEndpoint object

Basic database information.

vpc

CloudVpcInfo object

Information about the VPC, subnet, and security group where a DB instance resides.

ssl

EndpointSslConfig object

Information of the database SSL certificate.

enterprise_project_id

String

Enterprise project ID.

description

String

Description.

Table 10 ConnectionConfig

Parameter

Type

Description

driver_name

String

Driver name.

Table 11 BaseEndpoint

Parameter

Type

Description

id

String

Database information ID.

endpoint_name

String

Database scenario type. Values:

  • oracle: On-premises Oracle database.
  • ecs_oracle: Oracle database built on Huawei Cloud ECSs.
  • cloud_gaussdbv5: Huawei Cloud distributed GaussDB database.
  • mysql: MySQL database on other clouds or on-premises MySQL database.
  • ecs_mysql: MySQL database built on Huawei Cloud ECSs.
  • cloud_mysql: Huawei Cloud RDS for MySQL database.
  • redis: On-premises Redis database.
  • ecs_redis: Redis database built on Huawei Cloud ECSs.
  • rediscluster: On-premises Redis Cluster database.
  • ecs_rediscluster: Redis Cluster database built on Huawei Cloud ECSs.
  • cloud_gaussdb_redis: Huawei Cloud GeminiDB Redis database.
  • postgresql: On-premises PostgreSQL database.
  • ecs_postgresql: PostgreSQL database built on Huawei Cloud ECSs.
  • cloud_postgresql: Huawei Cloud RDS for PostgreSQL database.
  • mongodb: On-premises MongoDB database.
  • ecs_mongodb: MongoDB database built on Huawei Cloud ECSs.
  • cloud_mongodb: Huawei Cloud DDS database.

ip

String

Database IP address. If an on-premises MongoDB database is used, use colons (:) to separate the database IP address and port number, and use commas (,) to separate multiple values. A maximum of three IP addresses or domain names can be entered. If a DDS instance is used, use colons (:) to separate the database IP address and port number, and use commas (,) to separate multiple values. If a Redis Cluster database is used, enter the IP addresses and port numbers of all shards in the source Redis Cluster database. Use colons (:) to separate a database IP address and port number. Use commas (,) to separate multiple values. You are advised to enter the IP address of the slave node of a cluster shard. Up to 32 IP addresses or domain names can be entered. Use commas (,) to separate multiple IP addresses or domain names. Example: MySQL: ip; MongoDB: ip:port,ip:port,ip:port; DDS: ip:port,ip:port; Cluster Redis: ip:port,ip:port

db_port

String

Database port.

The value is an integer ranging from 1 to 65535.

db_user

String

Database username.

db_password

String

Database password.

instance_id

String

ID of a Huawei Cloud DB instance.

instance_name

String

Name of a Huawei Cloud DB instance.

db_name

String

Database name. For example:

  • oracle: serviceName.orcl.

source_sharding

Array of BaseEndpoint objects

Information about the physical source database.

Table 12 CloudVpcInfo

Parameter

Type

Description

vpc_id

String

ID of the VPC where a DB instance is located. To obtain the ID, perform the following steps:

Method 1: Log in to the VPC console and view the VPC ID on the VPC details page.

Method 2: Query the VPC ID through the VPC API. For details, see "Querying VPCs".

subnet_id

String

ID of the subnet where a DB instance is located. To obtain the ID, perform the following steps:

Method 1: Log in to the VPC console and click the target subnet on the Subnets page to view the network ID on the displayed page.

Method 2: Query the subnet ID through the VPC API. For details, see "Querying Subnets".

security_group_id

String

ID of the security group where a DB instance is located. To obtain the ID, perform the following steps:

Method 1: Log in to the 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.

Method 2: Query the security group through the VPC API. For details, see "Querying Security Groups".

Table 13 EndpointSslConfig

Parameter

Type

Description

ssl_link

Boolean

Whether SSL is enabled. If SSL is enabled, the value of this parameter is true.

ssl_cert_name

String

SSL certificate name.

ssl_cert_key

String

SSL certificate content, which is encrypted using Base64.

ssl_cert_check_sum

String

The checksum value of an SSL certificate, which is used for backend verification. This parameter is mandatory for secure connection to a source database.

ssl_cert_password

String

SSL certificate password. This parameter is mandatory if the certificate file name extension is .p12.

Status code: 400

Table 14 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Example Request

Creating a MySQL connection

https://{endpoint}/v5/5237e10fe9aa4ad5b16b6a5245248314/connections
{
  "name" : "DRS-mysql",
  "db_type" : "mysql",
  "description" : "description",
  "endpoint" : {
    "endpoint_name" : "mysql",
    "ip" : "127.0.0.1",
    "db_port" : "3306",
    "db_user" : "root",
    "db_password" : "password"
  },
  "ssl" : {
    "ssl_link" : false
  },
  "enterprise_project_id" : "0"
}

Example Response

Status code: 200

OK

{
  "name" : "DRS-mysql",
  "db_type" : "mysql",
  "endpoint" : {
    "endpoint_name" : "mysql",
    "ip" : "127.0.0.1",
    "db_port" : "3306",
    "db_user" : "root"
  },
  "description" : "description",
  "connection_id" : "835e1d79-24ac-411d-a1c8-22c000280659",
  "ssl" : {
    "ssl_link" : false
  },
  "create_time" : 1716879012121,
  "enterprise_project_id" : "0"
}

Status code: 400

Bad Request

{
  "error_code" : "DRS.10010065",
  "error_msg" : "Connection manager name is already exists."
}

Status Code

Status Code

Description

200

OK

400

Bad Request

Error Code

For details, see Error Code.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback