:original_name: CreateCaptureTask.html .. _CreateCaptureTask: Create capture task =================== Function -------- Create capture task URI --- POST /v1/{project_id}/capture-task .. table:: **Table 1** Path Parameters ========== ========= ====== =========== Parameter Mandatory Type Description ========== ========= ====== =========== project_id Yes String Project ID ========== ========= ====== =========== .. table:: **Table 2** Query Parameters +-----------------------+-----------+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Parameter | Mandatory | Type | Description | +=======================+===========+========+================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================+ | enterprise_project_id | No | String | Enterprise project id, the id generated by the enterprise project after the user supports the enterprise project, which can be obtained by calling the ListFirewallList. | +-----------------------+-----------+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | fw_instance_id | Yes | String | Firewall instance ID, which is automatically generated after a CFW instance is created. You can obtain the ID by calling the API used for querying a firewall instance. For details, see the API Explorer and Help Center FAQ.By default, if fw_instance_Id is not specified, information about the first firewall under the account is returned. If fw_instance_Id is specified, information about the firewall with this fw_instance_Id is returned.If object_Id is specified, information about the firewall with this object_Id is returned by default. If both fw_instance_Id and object_Id are specified, the specified object_Id must belong to the specified firewall. | +-----------------------+-----------+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Request Parameters ------------------ .. table:: **Table 3** Request header parameters +--------------+-----------+--------+----------------------------------------------------------------------------------------------------------------------------------------------------+ | Parameter | Mandatory | Type | Description | +==============+===========+========+====================================================================================================================================================+ | X-Auth-Token | No | String | User token. It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is a token. | +--------------+-----------+--------+----------------------------------------------------------------------------------------------------------------------------------------------------+ .. table:: **Table 4** Request body parameters +-----------------+-----------------+----------------------------------------------------------------------------------------+--------------------------+ | Parameter | Mandatory | Type | Description | +=================+=================+========================================================================================+==========================+ | destination | Yes | :ref:`CaptureRuleAddressDto ` object | capture rule address dto | +-----------------+-----------------+----------------------------------------------------------------------------------------+--------------------------+ | duration | Yes | Integer | capture duration | +-----------------+-----------------+----------------------------------------------------------------------------------------+--------------------------+ | max_packets | Yes | Integer | max packets | | | | | | | | | | Maximum: **1000000** | +-----------------+-----------------+----------------------------------------------------------------------------------------+--------------------------+ | name | Yes | String | capture name | +-----------------+-----------------+----------------------------------------------------------------------------------------+--------------------------+ | service | Yes | :ref:`CaptureServiceDto ` object | capture service dto | +-----------------+-----------------+----------------------------------------------------------------------------------------+--------------------------+ | source | Yes | :ref:`CaptureRuleAddressDto ` object | capture rule address dto | +-----------------+-----------------+----------------------------------------------------------------------------------------+--------------------------+ .. _createcapturetask__request_captureservicedto: .. table:: **Table 5** CaptureServiceDto +-------------+-----------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Parameter | Mandatory | Type | Description | +=============+===========+=========+==================================================================================================================================================================================================================+ | dest_port | No | String | destination port | +-------------+-----------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | protocol | Yes | Integer | Protocol type. The value 6 indicates TCP, 17 indicates UDP, 1 indicates ICMP, 58 indicates ICMPv6, and -1 indicates any protocol. Regarding the addition type, a null value indicates it is automatically added. | +-------------+-----------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | source_port | No | String | source port | +-------------+-----------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. _createcapturetask__request_captureruleaddressdto: .. table:: **Table 6** CaptureRuleAddressDto +--------------+-----------+---------+----------------------------------------------------------+ | Parameter | Mandatory | Type | Description | +==============+===========+=========+==========================================================+ | address | Yes | String | address | +--------------+-----------+---------+----------------------------------------------------------+ | address_type | Yes | Integer | Address type. The value can be 0 (IPv4), 1 (IPv6) | +--------------+-----------+---------+----------------------------------------------------------+ | type | Yes | Integer | input address type, manual means 0, only 0 is supported. | +--------------+-----------+---------+----------------------------------------------------------+ Response Parameters ------------------- **Status code: 200** .. table:: **Table 7** Response body parameters +-----------+---------------------------------------------------------------+-----------------------------------+ | Parameter | Type | Description | +===========+===============================================================+===================================+ | data | :ref:`IdObject ` object | create capture task response info | +-----------+---------------------------------------------------------------+-----------------------------------+ .. _createcapturetask__response_idobject: .. table:: **Table 8** IdObject ========= ====== =========== Parameter Type Description ========= ====== =========== id String ID name String name ========= ====== =========== Example Requests ---------------- Add a packet capture task to the project ID 09bb24e6fe80d23d2fa2c010b53b418c and the firewall id ebf891cd-2163-48a0-9963-6309f99dd3c4 with the task name zhuabaotest, the maximum number of packet captures is 100,000, the packet capture duration is 3 minutes, the remaining retention days are 7 days, the source address protocol is tcp protocol, and the address type is IPv4. The address is 1.1.1.1, the port number is 1-65535, the destination address protocol is TCP, the address type is IPv4, the address is 2.2.2.2, and the port number is 1-65535. .. code-block:: https://{Endpoint}/v1/09bb24e6fe80d23d2fa2c010b53b418c/capture-task?fw_instance_id=ebf891cd-2163-48a0-9963-6309f99dd3c4&enterprise_project_id=default { "name" : "zhuabaotest", "max_packets" : 100000, "duration" : 3, "hold_day" : 7, "source" : { "type" : 0, "address_type" : 0, "address" : "1.1.1.1" }, "destination" : { "type" : 0, "address_type" : 0, "address" : "2.2.2.2" }, "service" : { "protocol" : -1, "source_port" : "", "dest_port" : "" } } Example Responses ----------------- **Status code: 200** Create capture task response .. code-block:: { "data" : { "id" : "ebf891cd-2163-48a0-9963-6309f99dd3c4", "name" : "test" } } Status Codes ------------ =========== ============================ Status Code Description =========== ============================ 200 Create capture task response =========== ============================ Error Codes ----------- See :ref:`Error Codes `.