Ejemplo 3: Eliminación de instancias de DCS Redis en lotes
Escenario
Esta sección describe cómo eliminar instancias de DCS Redis en lotes mediante llamada a las API. Para obtener más información sobre cómo llamar a las API, consulte Llamadas a la API.
APIs involucradas
Llame a las API para realizar los siguientes pasos necesarios para eliminar instancias de DCS Redis en lotes:
Paso 1: Consultar los ID de las instancias que se van a eliminar
- Consultar los ID de instancia.
- URI
- Solicitud de ejemplo
GET https://{dcs_endpoint}/v2/7d80ae32f57b499eb8781f9a9f57c538/instances
Para obtener el valor de {dcs_endpoint}, consulte Regions y puntos de conexión.
- Ejemplo de respuesta
{ "instances": [{ "free": null, "max_memory": 1024, "used_memory": 2, "instance_id": "aabe73af-1db8-4401-b39c-c56996023989", "name": "dcs-8b1c-000", "resource_spec_code": "redis.ha.xu1.large.r2.1", "engine": "Redis", "engine_version": "5.0", "internal_version": null, "charging_mode": 0, "capacity": 1, "capacity_minor": null, "vpc_id": "cec3dca1-3700-4305-8eb0-5669c01f05b6", "vpc_name": null, "ip": "192.168.0.12", "domainName": "redis-aabe73a-dcs-8b1c-000.dcs.huaweicloud.com", "domain_name": "redis-aabe73a-dcs-8b1c-000.dcs.huaweicloud.com", "readonlyDomainName": null, "readonly_domain_name": null, "port": 6379, "status": "RUNNING", "freeze_scene": null, "created_at": "2020-06-18T03:11:30.615Z", "update_at": "2020-06-18T03:11:58.936Z", "error_code": null, "user_id": "05040c67cc00256f1f28c009a1c2a0f7", "user_name": "dcstest", "maintain_begin": "02:00:00", "maintain_end": "06:00:00", "no_password_access": "true", "access_user": null, "enable_publicip": false, "publicip_id": null, "publicip_address": null, "enable_ssl": false, "service_upgrade": false, "service_task_id": "", "enterprise_project_id": "0", "security_group_id": null, "tags": null, "product_type": "generic", "cpu_type": "x86_64", "storage_type": "DRAM", "task_status": null, "launched_at": "2020-06-18T03:11:58.945Z", "is_free": null, "libos": false, "cache_mode": "ha", "available_zones": ["dfeb4826256b47aa828e72d7522e108c", "043c7e39ecb347a08dc8fcb6c35a274e"], "subnet_id": "e6eb5ff4-da2a-4323-bddc-c7b179f9aa1e", "backend_addrs": null, "crr_role": null, "cloud_service_type_code": "hws.service.type.dcs", "cloud_resource_type_code": "hws.resource.type.dcs3", "support_slow_log_flag": null, "ipv6": null, "enable_ipv6": false, "description": "" }, { "free": null, "max_memory": 1024, "used_memory": 2, "instance_id": "9d78d0f4-a110-4bcd-8ca3-5aec414163c1", "name": "dcs-8b1c-001", "resource_spec_code": "redis.ha.xu1.large.r2.1", "engine": "Redis", "engine_version": "5.0", "internal_version": null, "charging_mode": 0, "capacity": 1, "capacity_minor": null, "vpc_id": "cec3dca1-3700-4305-8eb0-5669c01f05b6", "vpc_name": null, "ip": "192.168.0.33", "domainName": "redis-9d78d0f-dcs-8b1c-001.dcs.huaweicloud.com", "domain_name": "redis-9d78d0f-dcs-8b1c-001.dcs.huaweicloud.com", "readonlyDomainName": null, "readonly_domain_name": null, "port": 6379, "status": "RUNNING", "freeze_scene": null, "created_at": "2020-06-18T03:11:30.618Z", "update_at": "2020-06-18T03:11:58.937Z", "error_code": null, "user_id": "05040c67cc00256f1f28c009a1c2a0f7", "user_name": "dcstest", "maintain_begin": "02:00:00", "maintain_end": "06:00:00", "no_password_access": "true", "access_user": null, "enable_publicip": false, "publicip_id": null, "publicip_address": null, "enable_ssl": false, "service_upgrade": false, "service_task_id": "", "enterprise_project_id": "0", "security_group_id": null, "tags": null, "product_type": "generic", "cpu_type": "x86_64", "storage_type": "DRAM", "task_status": null, "launched_at": "2020-06-18T03:11:58.943Z", "is_free": null, "libos": false, "cache_mode": "ha", "available_zones": ["dfeb4826256b47aa828e72d7522e108c", "043c7e39ecb347a08dc8fcb6c35a274e"], "subnet_id": "e6eb5ff4-da2a-4323-bddc-c7b179f9aa1e", "backend_addrs": null, "crr_role": null, "cloud_service_type_code": "hws.service.type.dcs", "cloud_resource_type_code": "hws.resource.type.dcs3", "support_slow_log_flag": null, "ipv6": null, "enable_ipv6": false, "description": "" }], "instance_num": 2 }
- Registre la instancia_id de las instancias que se van a eliminar según sea necesario.
Paso 2: Eliminar instancias en lotes
- URI
- Solicitud de ejemplo
DELETE https://{dcs_endpoint}/v2/{project_id}/instances
Para obtener el valor de {dcs_endpoint}, consulte Regions y puntos de conexión.
Body:
{ "instances": [ "aabe73af-1db8-4401-b39c-c56996023989", "9d78d0f4-a110-4bcd-8ca3-5aec414163c1" ] }
- Ejemplo de respuesta
{ "results": [ { "result": "success", "instance": "aabe73af-1db8-4401-b39c-c56996023989" }, { "result": "success", "instance": "9d78d0f4-a110-4bcd-8ca3-5aec414163c1" } ] }
Para obtener más información sobre los parámetros para eliminar instancias de DCS Redis en lotes, consulte Eliminación por lotes de instancias DCS.