Creating Subscriptions
Function
This API is used to create subscriptions for a specified instance.
- Before calling this API, learn how to authenticate it.
- Before calling this API, learn about request header parameters.
Authorization Information
- If you are using role/policy-based authorization, see Permissions and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
|
Action |
Access Level |
Resource Type (*: required) |
Condition Key |
Alias |
Dependencies |
|---|---|---|---|---|---|
|
rds:instance:update |
write |
- |
- |
rds:instance:modify |
- |
URI
- Parameter description
Table 1 Parameters Parameter
Mandatory
Description
project_id
Yes
Definition
Project ID of a tenant in a region.
To obtain the value, see Obtaining a Project ID.
Constraints
The value cannot be empty.
Range
N/A
Default Value
N/A
instance_id
Yes
Definition
Instance ID.
Constraints
The value cannot be empty.
Range
N/A
Default Value
N/A
Request
- Parameter description
Table 2 Parameters Parameter
Mandatory
Type
Description
subscriptions
Yes
Array of objects
Definition
Subscription information.
For details, see Table 3.
Constraints
You can create a maximum of 10 subscriptions at a time.
current_publication_id
No
String
Definition
ID of the publication that subscriptions are created for.
Constraints
This parameter is mandatory when subscriptions are created for a publication. If this parameter is not specified, local subscriptions are created.
Range
N/A
Default Value
N/A
Table 3 subscriptions element structure description Parameter
Mandatory
Type
Description
subscription_database
Yes
String
Definition
Subscription database name.
Constraints
N/A
Range
N/A
Default Value
N/A
subscription_type
Yes
String
Definition
Subscription type.
Constraints
N/A
Range
push
Default Value
push
initialize_at
Yes
String
Definition
Initialization type.
Constraints
N/A
Range
- do_not: no initialization
- immediate: immediate initialization
- at_first_sync: initialized upon initial synchronization
Default Value
do_not
job_schedule
Yes
Object
Definition
Synchronization schedule.
For details, see Table 4.
Constraints
N/A
initialize_info
No
Object
Definition
Initialization information.
For details, see Table 9.
Constraints
N/A
independent_agent
No
Boolean
Definition
Whether an independent distribution agent is used.
Constraints
N/A
Range
- true: An agent is used.
- false: No agent is used.
Default Value
true
bak_file_name
No
String
Definition
Backup file name. If the value is not empty, the initialization uses the backup file.
Constraints
N/A
Range
N/A
Default Value
N/A
bak_bucket_name
No
String
Definition
Name of the OBS bucket where the backup file is stored.
Constraints
N/A
Range
- If bak_file_name is left empty, bak_bucket_name is invalid.
- If bak_bucket_name is left empty, the backup file is from RDS.
- If bak_bucket_name is not left empty, the backup file is from your OBS bucket.
Default Value
N/A
publication_subscription
No
Object
Definition
Subscription information of the publication.
For details, see Table 10.
Constraints
This parameter is mandatory when subscriptions are created for a publication.
local_subscription
No
Object
Definition
Local subscription information.
For details, see Table 12.
Constraints
This parameter is mandatory when local subscriptions are created.
Table 4 job_schedule element structure description Parameter
Mandatory
Type
Description
id
No
String
Definition
Schedule ID.
Constraints
N/A
Range
N/A
Default Value
N/A
job_schedule_type
No
String
Definition
Schedule type.
Constraints
N/A
Range
- cpu_idle: The task starts when the CPU is idle.
- recurring: The task is executed repeatedly.
- one_time: The task is executed only once.
- automatically: The task starts when the SQL Server Agent is started.
Default Value
recurring
one_time_occurrence
No
Object
Definition
Execution time when the task is executed only once.
For details, see Table 5.
Constraints
N/A
frequency
No
Object
Definition
Interval of the schedule.
For details, see Table 6.
Constraints
This parameter is mandatory only when the schedule ID is empty.
daily_frequency
No
Object
Definition
Daily frequency of the schedule.
For details, see Table 7.
Constraints
This parameter is mandatory only when the schedule ID is empty.
duration
No
Object
Definition
Validity period of the schedule.
For details, see Table 8.
Constraints
This parameter is mandatory only when the schedule ID is empty.
Table 5 one_time_occurrence element structure description Parameter
Mandatory
Type
Description
active_start_date
No
String
Definition
Execution date, in the format of yyyy-MM-dd.
Constraints
N/A
Range
1990-01-01 to 2099-12-31
Default Value
N/A
active_start_time
No
String
Definition
Execution time, in the format of HH:mm:ss.
Constraints
N/A
Range
N/A
Default Value
N/A
Table 6 frequency element structure description Parameter
Mandatory
Type
Description
freq_type
No
String
Definition
Frequency type of the schedule.
Constraints
N/A
Range
- daily: by day
- weekly: by week
- monthly_day: by month and by day in each month
- monthly_week: by month and by week in each month
Default Value
N/A
freq_interval
No
Integer
Definition
Execution interval.
Constraints
N/A
Range
1–99
Default Value
N/A
freq_interval_weekly
No
Array of strings
Definition
Days in a week when the task is executed.
Constraints
This parameter is mandatory when freq_type is set to weekly. If freq_type is not set to weekly, this parameter does not take effect.
Range
Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
Default Value
N/A
freq_interval_day_monthly
No
Integer
Definition
Monthly execution dates.
Constraints
This parameter is mandatory when freq_type is set to monthly_day. If freq_type is not set to monthly_day, this parameter does not take effect.
Range
1 to the total number of days in the month, for example, 1 to 31
Default Value
N/A
freq_interval_monthly
No
String
Definition
Days in a week when the task is executed in the current month.
Constraints
This parameter is mandatory when freq_type is set to monthly_week. If freq_type is not set to monthly_week, this parameter does not take effect.
Range
Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, day, weekday, weekend
Default Value
N/A
freq_relative_interval_monthly
No
String
Definition
Week in a month when the task is executed.
Constraints
This parameter is mandatory when freq_type is set to monthly_week. If freq_type is not set to monthly_week, this parameter does not take effect.
Range
first, second, third, fourth, last
Default Value
N/A
Table 7 daily_frequency element structure description Parameter
Mandatory
Type
Description
freq_subday_type
No
String
Definition
Daily frequency type.
Constraints
N/A
Range
- once: once a day
- multiple: multiple times a day
Default Value
N/A
active_start_time
No
String
Definition
Time of the first execution on each day. If freq_subday_type is set to once, the task is executed only once a day. The value is in HH:mm:ss format.
Constraints
N/A
Range
N/A
Default Value
N/A
active_end_time
No
String
Definition
Last execution time, in the format of HH:mm:ss.
Constraints
This parameter is mandatory when the task is executed multiple times a day. It does not take effect when the task is executed only once a day.
Range
N/A
Default Value
N/A
freq_subday_interval
No
Integer
Definition
Execution interval.
Constraints
This parameter is mandatory when the task is executed multiple times a day. It does not take effect when the task is executed only once a day.
Range
1–99
Default Value
N/A
freq_interval_unit
No
String
Definition
Execution interval unit.
Constraints
This parameter is mandatory when the task is executed multiple times a day. It does not take effect when the task is executed only once a day.
Range
- second
- minute
- hour
Default Value
N/A
Table 8 duration element structure description Parameter
Mandatory
Type
Description
active_start_date
No
String
Definition
First execution date, in the format of yyyy-MM-dd.
Constraints
N/A
Range
1990-01-01 to 2099-12-31
Default Value
N/A
active_end_date
No
String
Definition
Last execution date, in the format of yyyy-MM-dd. By default, the execution does not end.
Constraints
N/A
Range
N/A
Default Value
N/A
Table 9 initialize_info element structure description Parameter
Mandatory
Type
Description
file_source
No
String
Definition
File source used for initialization.
Constraints
N/A
Range
OBS or BACKUP
Default Value
N/A
backup_id
No
String
Definition
ID of the backup file used for initialization.
Constraints
N/A
Range
N/A
Default Value
N/A
bucket_name
No
String
Definition
Name of the OBS bucket where the backup file is stored.
Constraints
N/A
Range
N/A
Default Value
N/A
file_path
No
String
Definition
Path of the backup file in the OBS bucket.
Constraints
N/A
Range
N/A
Default Value
N/A
file_name
No
String
Definition
Name of the backup file in the OBS bucket.
Constraints
N/A
Range
N/A
Default Value
N/A
overwrite_restore
No
Boolean
Definition
Whether to use the backup file to overwrite the subscription database.
Constraints
N/A
Range
N/A
Default Value
N/A
Table 10 publication_subscription element structure description Parameter
Mandatory
Type
Description
subscription_instance_id
Yes
String
Definition
Subscriber instance ID when the subscriber is a cloud instance.
Constraints
N/A
Range
N/A
Default Value
N/A
user_info
No
Object
Definition
Login information when the subscriber is not a cloud instance. (This parameter is valid only when the subscriber instance ID is empty.)
For details, see Table 11.
Constraints
N/A
Table 11 user_info element structure description Parameter
Mandatory
Type
Description
server_ip
Yes
String
Definition
Server IP address.
Constraints
N/A
Range
N/A
Default Value
N/A
server_port
Yes
Integer
Definition
Port number.
Constraints
N/A
Range
N/A
Default Value
N/A
server_name
Yes
String
Definition
Server name.
Constraints
N/A
Range
N/A
Default Value
N/A
login_user_name
Yes
String
Definition
Login name.
Constraints
N/A
Range
N/A
Default Value
N/A
login_user_password
Yes
String
Definition
Login password.
Constraints
N/A
Range
5 to 64 characters
Default Value
N/A
Table 12 local_subscription element structure description Parameter
Mandatory
Type
Description
publication_id
Yes
String
Definition
Publication ID of the cloud instance when local subscriptions are created.
Constraints
N/A
Range
N/A
Default Value
N/A
publication_name
No
String
Definition
Publication name of the cloud instance when local subscriptions are created.
Constraints
N/A
Range
N/A
Default Value
N/A
- URI example
POST https://rds.ap-southeast-1.myhuaweicloud.com/v3/0483b6b16e954cb88930a360d2c4e663/instances/72ee4cc4607347049df9ad50f615bbd8in04/replication/subscriptions
- Example request
Create subscriptions for a publication.
{ "current_publication_id": "942d9062-4fb9-48ce-bfe1-15655560ad56", "subscriptions": [ { "subscription_database": "db-2-01", "subscription_type": "push", "initialize_at": "immediate", "job_schedule": { "id": "569d69c2-53e5-4bef-a356-d7ea2ff6fb98", "frequency": { }, "daily_frequency": { }, "duration": { }, "job_schedule_type": "automatically", "one_time_occurrence": { "active_start_date": "2019-12-31", "active_start_date": "02:00:00" } }, "publication_subscription": { "subscription_instance_id": "a64ba793eee740cb9f315f564b2e135din04" } } ] }
Create local subscriptions.
{
"subscriptions": [
{
"subscription_database": "sadas",
"subscription_type": "push",
"initialize_at": "do_not",
"job_schedule": {
"id": "569d69c2-53e5-4bef-a356-d7ea2ff6fb98",
"frequency": {
},
"daily_frequency": {
},
"duration": {
},
"job_schedule_type": "automatically",
"one_time_occurrence": {
}
},
"local_subscription": {
"publication_id": "cef678d8-fce7-4d17-8621-e6577b52f298",
"publication_name": "pub01"
}
}
]
}
Response
- Normal response
Table 13 Parameters Parameter
Type
Description
job_id
String
Definition
Task ID.
Range
N/A
- Example normal response
{ "job_id": "374a2954-fa5d-4e7b-89a2-c3b8a0af8ea8" } - Abnormal response
For details, see Abnormal Request Results.
Status Code
- Normal
- Abnormal
For details, see Status Codes.
Error Code
For details, see Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot