文档首页 > > API参考> 应用示例>

示例1:更新DDoS防护

示例1:更新DDoS防护

分享
更新时间:2020/11/25 GMT+08:00

场景描述

当您需要更新某个ip的防护策略时,您可以通过Anti-DDoS界面在线修改,或者调用Anti-DDoS的API接口修改。

流程如下:
  1. 用户先查询名下所有主机的配置监控状态。
  2. 用户再查询AntiDDOS服务的配置列表。
  3. 用户根据配置参数,修改ip的防护策略为目标策略。
  4. 用户根据返回的任务id,查询任务的执行情况。

涉及接口

更新DDoS防护时,涉及的接口如下:

操作步骤

  1. 批量查询用户所有主机的配置监控状态。

    • 接口相关信息

      URI格式:GET /v1/{project_id}/antiddos

      详情请参见“查询EIP防护状态列表”。

    • 请求示例

      GET: https://{endpoint}/v1/1858a4e1f99d4454bd6a539d5477f5de/antiddos

      {endpoint}信息请从地区和终端节点获取。

      Body:

      {
      }
    • 响应示例
      {
      "total": 1,
      "ddosStatus": [
      {
      "floating_ip_id": "18e6ace5-eb36-4196-a15e-1e000c24e026",
      "floating_ip_address": "139.9.116.167",
      "network_type": "EIP",
      "status": "normal",
      "blackhole_endtime": 0,
      "protect_type": "default",
      "traffic_threshold": 99,
      "http_threshold": 0
      }
      ]
      }

  2. 查询AntiDDOS服务的配置列表。

    • 接口相关信息

      URI格式:GET /v2/{project_id}/antiddos/query-config-list

      详情请参见“查询Anti-DDoS配置可选范围”。

    • 请求示例

      GET: https://{endpoint}/v2/1858a4e1f99d4454bd6a539d5477f5de/antiddos/query-config-list

      {endpoint}信息请从地区和终端节点获取。

      Body:

      {
      }
    • 响应示例
      {
      "traffic_limited_list": [
      {
      "traffic_pos_id": 1,
      "traffic_per_second": 10,
      "packet_per_second": 2000
      },
      {
      "traffic_pos_id": 2,
      "traffic_per_second": 30,
      "packet_per_second": 6000
      },
      {
      "traffic_pos_id": 3,
      "traffic_per_second": 50,
      "packet_per_second": 10000
      },
      {
      "traffic_pos_id": 4,
      "traffic_per_second": 70,
      "packet_per_second": 15000
      },
      {
      "traffic_pos_id": 5,
      "traffic_per_second": 100,
      "packet_per_second": 20000
      },
      {
      "traffic_pos_id": 6,
      "traffic_per_second": 150,
      "packet_per_second": 25000
      },
      {
      "traffic_pos_id": 7,
      "traffic_per_second": 200,
      "packet_per_second": 35000
      },
      {
      "traffic_pos_id": 8,
      "traffic_per_second": 250,
      "packet_per_second": 50000
      },
      {
      "traffic_pos_id": 9,
      "traffic_per_second": 300,
      "packet_per_second": 70000
      },
      {
      "traffic_pos_id": 88,
      "traffic_per_second": 1000,
      "packet_per_second": 300000
      }
      ],
      "http_limited_list": [
      {
      "http_request_pos_id": 1,
      "http_packet_per_second": 100
      },
      {
      "http_request_pos_id": 2,
      "http_packet_per_second": 150
      },
      {
      "http_request_pos_id": 3,
      "http_packet_per_second": 240
      },
      {
      "http_request_pos_id": 4,
      "http_packet_per_second": 350
      },
      {
      "http_request_pos_id": 5,
      "http_packet_per_second": 480
      },
      {
      "http_request_pos_id": 6,
      "http_packet_per_second": 550
      },
      {
      "http_request_pos_id": 7,
      "http_packet_per_second": 700
      },
      {
      "http_request_pos_id": 8,
      "http_packet_per_second": 850
      },
      {
      "http_request_pos_id": 9,
      "http_packet_per_second": 1000
      },
      {
      "http_request_pos_id": 10,
      "http_packet_per_second": 1500
      },
      {
      "http_request_pos_id": 11,
      "http_packet_per_second": 2000
      },
      {
      "http_request_pos_id": 12,
      "http_packet_per_second": 3000
      },
      {
      "http_request_pos_id": 13,
      "http_packet_per_second": 5000
      },
      {
      "http_request_pos_id": 14,
      "http_packet_per_second": 10000
      },
      {
      "http_request_pos_id": 15,
      "http_packet_per_second": 20000
      }
      ],
      "connection_limited_list": [
      {
      "cleaning_access_pos_id": 1,
      "new_connection_limited": 10,
      "total_connection_limited": 30
      },
      {
      "cleaning_access_pos_id": 2,
      "new_connection_limited": 20,
      "total_connection_limited": 100
      },
      {
      "cleaning_access_pos_id": 3,
      "new_connection_limited": 30,
      "total_connection_limited": 200
      },
      {
      "cleaning_access_pos_id": 4,
      "new_connection_limited": 40,
      "total_connection_limited": 250
      },
      {
      "cleaning_access_pos_id": 5,
      "new_connection_limited": 50,
      "total_connection_limited": 300
      },
      {
      "cleaning_access_pos_id": 6,
      "new_connection_limited": 60,
      "total_connection_limited": 500
      },
      {
      "cleaning_access_pos_id": 7,
      "new_connection_limited": 70,
      "total_connection_limited": 600
      },
      {
      "cleaning_access_pos_id": 8,
      "new_connection_limited": 80,
      "total_connection_limited": 700
      }
      ],
      "extend_ddos_config": []
      }

  3. 更新IP的AntiDDoS安全服务配置。

    • 接口相关信息

      URI格式:PUT /v1/{project_id}/antiddos/{floating_ip_id}

      详情请参见“更新Anti-DDoS服务”。

    • 请求示例

      PUT: https://{endpoint}/v1/1858a4e1f99d4454bd6a539d5477f5de/antiddos/18e6ace5-eb36-4196-a15e-1e000c24e026

      {endpoint}信息请从地区和终端节点获取。

      Body:

      {
      "app_type_id": 1,
      "cleaning_access_pos_id": 8,
      "enable_L7": false,
      "http_request_pos_id": 8,
      "traffic_pos_id": 8
      }
    • 响应示例
      {
      "error_code": "10000000",
      "error_msg": "The task has been received and is being handled",
      "task_id": "59385d2a-6266-4d3a-9122-a228c530f557"
      }

  4. 根据任务ID获取任务状态。

    • 接口相关信息

      URI格式:GET /v2/{project_id}/query-task-status

      详情请参见“查询Anti-DDoS任务”。

    • 请求示例

      GET: https://{endpoint}/v2/1858a4e1f99d4454bd6a539d5477f5de/query-task-status?task_id=59385d2a-6266-4d3a-9122-a228c530f557

      {endpoint}信息请从地区和终端节点获取。

      Body:

      {
      }
    • 响应示例
      {
      "task_status": "success",
      "task_msg": ""
      }

分享:

    相关文档

    相关产品