Chilkat Online Tools

DataFlex / Datadog API Collection / Get all archives

Back to Collection Items

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sV_type
    String sName
    String sQuery
    String sStorage_account
    String sContainer
    String sTenant_id
    String sClient_id
    String sV_Type
    String sPath
    String sRegion
    Boolean iInclude_tags
    String sRehydration_max_scan_size_in_gb
    String sState
    String sId
    Integer j
    Integer iCount_j
    String sStrVal
    Integer i
    Integer iCount_i
    String sTemp1

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    Send ComSetRequestHeader To hoHttp "Accept" "application/json"

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComQuickGetSb Of hoHttp "https://api.app.ddog-gov.com/api/v2/logs/config/archives" vSbResponseBody To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJResp To sTemp1
    Showln sTemp1

    Get ComLastStatus Of hoHttp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComLastHeader Of hoHttp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Procedure_Return
    End

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "data": [
    //     {
    //       "type": "archives",
    //       "attributes": {
    //         "name": "<string>",
    //         "query": "<string>",
    //         "destination": {
    //           "storage_account": "<string>",
    //           "container": "<string>",
    //           "integration": {
    //             "tenant_id": "<string>",
    //             "client_id": "<string>"
    //           },
    //           "type": "azure",
    //           "path": "<string>",
    //           "region": "<string>"
    //         },
    //         "include_tags": false,
    //         "rehydration_max_scan_size_in_gb": "<long>",
    //         "rehydration_tags": [
    //           "<string>",
    //           "<string>"
    //         ],
    //         "state": "FAILING"
    //       },
    //       "id": "<string>"
    //     },
    //     {
    //       "type": "archives",
    //       "attributes": {
    //         "name": "<string>",
    //         "query": "<string>",
    //         "destination": {
    //           "storage_account": "<string>",
    //           "container": "<string>",
    //           "integration": {
    //             "tenant_id": "<string>",
    //             "client_id": "<string>"
    //           },
    //           "type": "azure",
    //           "path": "<string>",
    //           "region": "<string>"
    //         },
    //         "include_tags": false,
    //         "rehydration_max_scan_size_in_gb": "<long>",
    //         "rehydration_tags": [
    //           "<string>",
    //           "<string>"
    //         ],
    //         "state": "WORKING_AUTH_LEGACY"
    //       },
    //       "id": "<string>"
    //     }
    //   ]
    // }

    // Sample code for parsing the JSON response...
    // Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "data" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "data[i].type" To sV_type
        Get ComStringOf Of hoJResp "data[i].attributes.name" To sName
        Get ComStringOf Of hoJResp "data[i].attributes.query" To sQuery
        Get ComStringOf Of hoJResp "data[i].attributes.destination.storage_account" To sStorage_account
        Get ComStringOf Of hoJResp "data[i].attributes.destination.container" To sContainer
        Get ComStringOf Of hoJResp "data[i].attributes.destination.integration.tenant_id" To sTenant_id
        Get ComStringOf Of hoJResp "data[i].attributes.destination.integration.client_id" To sClient_id
        Get ComStringOf Of hoJResp "data[i].attributes.destination.type" To sV_Type
        Get ComStringOf Of hoJResp "data[i].attributes.destination.path" To sPath
        Get ComStringOf Of hoJResp "data[i].attributes.destination.region" To sRegion
        Get ComBoolOf Of hoJResp "data[i].attributes.include_tags" To iInclude_tags
        Get ComStringOf Of hoJResp "data[i].attributes.rehydration_max_scan_size_in_gb" To sRehydration_max_scan_size_in_gb
        Get ComStringOf Of hoJResp "data[i].attributes.state" To sState
        Get ComStringOf Of hoJResp "data[i].id" To sId
        Move 0 To j
        Get ComSizeOfArray Of hoJResp "data[i].attributes.rehydration_tags" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "data[i].attributes.rehydration_tags[j]" To sStrVal
            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop



End_Procedure

Curl Command

curl -X GET
	-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v2/logs/config/archives

Postman Collection Item JSON

{
  "name": "Get all archives",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/logs/config/archives",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "logs",
        "config",
        "archives"
      ]
    },
    "description": "Get the list of configured logs archives with their definitions."
  },
  "response": [
    {
      "name": "OK",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v2/logs/config/archives",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "logs",
            "config",
            "archives"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"data\": [\n    {\n      \"type\": \"archives\",\n      \"attributes\": {\n        \"name\": \"<string>\",\n        \"query\": \"<string>\",\n        \"destination\": {\n          \"storage_account\": \"<string>\",\n          \"container\": \"<string>\",\n          \"integration\": {\n            \"tenant_id\": \"<string>\",\n            \"client_id\": \"<string>\"\n          },\n          \"type\": \"azure\",\n          \"path\": \"<string>\",\n          \"region\": \"<string>\"\n        },\n        \"include_tags\": false,\n        \"rehydration_max_scan_size_in_gb\": \"<long>\",\n        \"rehydration_tags\": [\n          \"<string>\",\n          \"<string>\"\n        ],\n        \"state\": \"FAILING\"\n      },\n      \"id\": \"<string>\"\n    },\n    {\n      \"type\": \"archives\",\n      \"attributes\": {\n        \"name\": \"<string>\",\n        \"query\": \"<string>\",\n        \"destination\": {\n          \"storage_account\": \"<string>\",\n          \"container\": \"<string>\",\n          \"integration\": {\n            \"tenant_id\": \"<string>\",\n            \"client_id\": \"<string>\"\n          },\n          \"type\": \"azure\",\n          \"path\": \"<string>\",\n          \"region\": \"<string>\"\n        },\n        \"include_tags\": false,\n        \"rehydration_max_scan_size_in_gb\": \"<long>\",\n        \"rehydration_tags\": [\n          \"<string>\",\n          \"<string>\"\n        ],\n        \"state\": \"WORKING_AUTH_LEGACY\"\n      },\n      \"id\": \"<string>\"\n    }\n  ]\n}"
    },
    {
      "name": "Forbidden",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v2/logs/config/archives",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "logs",
            "config",
            "archives"
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"<string>\",\n    \"<string>\"\n  ]\n}"
    },
    {
      "name": "Too many requests",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v2/logs/config/archives",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "logs",
            "config",
            "archives"
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"<string>\",\n    \"<string>\"\n  ]\n}"
    }
  ]
}