create_site_cname_record
Creates a CNAME DNS record for a website, linking it to a target domain. Specify site ID, record name, and origin domain to manage DNS configurations effectively.
Instructions
Creates a DNS record for a specific website. Only supports records with type=CNAME and sourceType=Domain.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bizName | No | The business scenario of the record for acceleration. Leave the parameter empty if your record is not proxied. Valid values: - image_video - api - web | |
| comment | No | The comment of the record. The maximum length is 100 characters. | |
| data | Yes | The DNS record information. The format of this field varies based on the record type. For more information, see https://www.alibabacloud.com/help/doc-detail/2708761.html | |
| hostPolicy | No | The origin host policy. This policy takes effect when the record type is CNAME. Required. You can set the policy in two modes: - follow_hostname - follow_origin_domain | |
| recordName | Yes | The record name. | |
| siteId | Yes | The website ID, which can be obtained by calling the [ListSites] operation. | |
| sourceType | No | The origin type for the CNAME record. This parameter is required when you add a CNAME record. Valid values: - Domain: domain name If you do not pass this parameter or if you leave its value empty, Domain is used by default. | |
| ttl | No | The TTL of the record. Unit: seconds. If the value is 1, the TTL of the record is determined by the system. Default: 1. |
Implementation Reference
- src/tools/site/record.ts:665-686 (handler)The main handler function that executes the tool logic: prepares the CreateRecordRequest for CNAME type with sourceType 'Domain', proxies it, calls api.createRecord, and returns the JSON response.export const create_site_cname_record = async (request: CallToolRequest) => { const req = request.params.arguments as CreateRecordRequest; req.type = 'CNAME'; req.sourceType = 'Domain'; req.proxied = true; req.ttl = req.ttl || 1; if (req.sourceType !== 'Domain') { return { content: [{ type: 'text', text: 'sourceType must be Domain' }], success: false, }; } const res = await api.createRecord(req); return { content: [{ type: 'text', text: JSON.stringify(res) }], success: true, }; };
- src/tools/site/record.ts:88-158 (schema)The Tool object defining the schema, input parameters, description, and annotations for the create_site_cname_record tool.export const CREATE_SITE_CNAME_RECORD_TOOL: Tool = { name: 'create_site_cname_record', description: 'Creates a DNS record for a specific website. Only supports records with type=CNAME and sourceType=Domain.', inputSchema: { type: 'object', properties: { siteId: { type: 'number', description: 'The website ID, which can be obtained by calling the [ListSites] operation.', }, recordName: { type: 'string', description: 'The record name.', examples: ['www.example.com'], }, sourceType: { type: 'string', description: 'The origin type for the CNAME record. This parameter is required when you add a CNAME record. Valid values:\n- Domain: domain name\n\nIf you do not pass this parameter or if you leave its value empty, Domain is used by default.', enum: ['Domain'], examples: ['Domain'], }, bizName: { type: 'string', description: 'The business scenario of the record for acceleration. Leave the parameter empty if your record is not proxied. Valid values:\n- image_video\n- api\n- web', enum: ['image_video', 'api', 'web'], examples: ['web'], }, ttl: { type: 'number', description: 'The TTL of the record. Unit: seconds. If the value is 1, the TTL of the record is determined by the system. Default: 1.', examples: [1], }, data: { type: 'object', description: 'The DNS record information. The format of this field varies based on the record type. For more information, see https://www.alibabacloud.com/help/doc-detail/2708761.html', properties: { value: { type: 'string', description: 'The target domain name. Required.', example: ['origin.example.com'], }, }, }, comment: { type: 'string', description: 'The comment of the record. The maximum length is 100 characters.', }, hostPolicy: { type: 'string', description: 'The origin host policy. This policy takes effect when the record type is CNAME. Required. You can set the policy in two modes:\n- follow_hostname\n- follow_origin_domain', enum: ['follow_hostname', 'follow_origin_domain'], examples: ['follow_hostname'], }, }, required: ['siteId', 'recordName', 'type', 'data'], annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false, }, }, };
- src/tools/list-esa-function.ts:164-208 (registration)The esaHandlers object registers the create_site_cname_record handler function along with other ESA tool handlers.export const esaHandlers: ToolHandlers = { site_active_list, site_match, site_route_list, site_record_list, routine_create, routine_code_commit, routine_delete, routine_list, routine_get, routine_code_deploy, routine_route_list, deployment_delete, route_create, route_delete, route_update, route_get, er_record_create, er_record_delete, er_record_list, html_deploy, create_site, update_site_pause, get_site_pause, create_site_mx_record, create_site_ns_record, create_site_txt_record, create_site_cname_record, create_site_a_or_aaaa_record, update_record, list_records, get_record, delete_record, update_ipv6, get_ipv6, update_managed_transform, get_managed_transform, set_certificate, apply_certificate, get_certificate, delete_certificate, list_certificates, get_certificate_quota, list_sites, };
- src/tools/list-esa-function.ts:130-139 (registration)The ESA_OPENAPI_SITE_LIST array registers the CREATE_SITE_CNAME_RECORD_TOOL schema.UPDATE_RECORD_TOOL, CREATE_SITE_MX_RECORD_TOOL, CREATE_SITE_NS_RECORD_TOOL, CREATE_SITE_TXT_RECORD_TOOL, CREATE_SITE_CNAME_RECORD_TOOL, CREATE_SITE_A_OR_AAAA_RECORD_TOOL, DELETE_RECORD_TOOL, LIST_RECORDS_TOOL, GET_RECORD_TOOL, ];