Chilkat Online Tools

DataFlex / Datadog API Collection / Create an SLO correction

Back to Collection Items

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vJson
    Handle hoJson
    Variant vResp
    Handle hoResp
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sCategory
    Integer iCreated_at
    String sV_Email
    String sHandle
    String sName
    String sDescription
    Integer iDuration
    Integer iV_End
    Integer iModified_at
    String sModifierEmail
    String sModifierHandle
    String sModifierName
    String sRrule
    String sSlo_id
    Integer iStart
    String sTimezone
    String sId
    String sV_Type
    String sTemp1
    Boolean bTemp1

    // 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

    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "data": {
    //     "type": "correction",
    //     "attributes": {
    //       "slo_id": "sloId",
    //       "start": 1600000000,
    //       "category": "Scheduled Maintenance",
    //       "description": "reprehend",
    //       "duration": 1600000000,
    //       "end": 1600000000,
    //       "rrule": "FREQ=DAILY;INTERVAL=10;COUNT=5",
    //       "timezone": "UTC"
    //     }
    //   }
    // }

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "data.type" "correction" To iSuccess
    Get ComUpdateString Of hoJson "data.attributes.slo_id" "sloId" To iSuccess
    Get ComUpdateInt Of hoJson "data.attributes.start" 1600000000 To iSuccess
    Get ComUpdateString Of hoJson "data.attributes.category" "Scheduled Maintenance" To iSuccess
    Get ComUpdateString Of hoJson "data.attributes.description" "reprehend" To iSuccess
    Get ComUpdateInt Of hoJson "data.attributes.duration" 1600000000 To iSuccess
    Get ComUpdateInt Of hoJson "data.attributes.end" 1600000000 To iSuccess
    Get ComUpdateString Of hoJson "data.attributes.rrule" "FREQ=DAILY;INTERVAL=10;COUNT=5" To iSuccess
    Get ComUpdateString Of hoJson "data.attributes.timezone" "UTC" To iSuccess

    Send ComSetRequestHeader To hoHttp "Content-Type" "application/json"
    Send ComSetRequestHeader To hoHttp "Accept" "application/json"

    Get pvComObject of hoJson to vJson
    Get ComPostJson3 Of hoHttp "https://api.app.ddog-gov.com/api/v1/slo/correction" "application/json" vJson To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess

    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 ComStatusCode Of hoResp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComHeader Of hoResp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Send Destroy of hoResp
        Procedure_Return
    End

    Send Destroy of hoResp

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

    // {
    //   "data": {
    //     "attributes": {
    //       "category": "Scheduled Maintenance",
    //       "created_at": 11806311,
    //       "creator": {
    //         "email": "dolor nisi",
    //         "handle": "la",
    //         "name": "in quis est cillum"
    //       },
    //       "description": "nostrud amet ea exercitation",
    //       "duration": 3600,
    //       "end": 30790629,
    //       "modified_at": 77538107,
    //       "modifier": {
    //         "email": "pariatur nisi minim reprehenderit",
    //         "handle": "irure commodo",
    //         "name": "veniam"
    //       },
    //       "rrule": "FREQ=DAILY;INTERVAL=10;COUNT=5",
    //       "slo_id": "incididunt qui velit sunt labore",
    //       "start": -34398281,
    //       "timezone": "eu id"
    //     },
    //     "id": "enim qui",
    //     "type": "correction"
    //   }
    // }

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

    Get ComStringOf Of hoJResp "data.attributes.category" To sCategory
    Get ComIntOf Of hoJResp "data.attributes.created_at" To iCreated_at
    Get ComStringOf Of hoJResp "data.attributes.creator.email" To sV_Email
    Get ComStringOf Of hoJResp "data.attributes.creator.handle" To sHandle
    Get ComStringOf Of hoJResp "data.attributes.creator.name" To sName
    Get ComStringOf Of hoJResp "data.attributes.description" To sDescription
    Get ComIntOf Of hoJResp "data.attributes.duration" To iDuration
    Get ComIntOf Of hoJResp "data.attributes.end" To iV_End
    Get ComIntOf Of hoJResp "data.attributes.modified_at" To iModified_at
    Get ComStringOf Of hoJResp "data.attributes.modifier.email" To sModifierEmail
    Get ComStringOf Of hoJResp "data.attributes.modifier.handle" To sModifierHandle
    Get ComStringOf Of hoJResp "data.attributes.modifier.name" To sModifierName
    Get ComStringOf Of hoJResp "data.attributes.rrule" To sRrule
    Get ComStringOf Of hoJResp "data.attributes.slo_id" To sSlo_id
    Get ComIntOf Of hoJResp "data.attributes.start" To iStart
    Get ComStringOf Of hoJResp "data.attributes.timezone" To sTimezone
    Get ComStringOf Of hoJResp "data.id" To sId
    Get ComStringOf Of hoJResp "data.type" To sV_Type


End_Procedure

Curl Command

curl -X POST
	-H "Content-Type: application/json"
	-H "Accept: application/json"
	-d '{
  "data": {
    "type": "correction",
    "attributes": {
      "slo_id": "sloId",
      "start": 1600000000,
      "category": "Scheduled Maintenance",
      "description": "reprehend",
      "duration": 1600000000,
      "end": 1600000000,
      "rrule": "FREQ=DAILY;INTERVAL=10;COUNT=5",
      "timezone": "UTC"
    }
  }
}'
https://api.app.ddog-gov.com/api/v1/slo/correction

Postman Collection Item JSON

{
  "name": "Create an SLO correction",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      },
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n  \"data\": {\n    \"type\": \"correction\",\n    \"attributes\": {\n      \"slo_id\": \"sloId\",\n      \"start\": 1600000000,\n      \"category\": \"Scheduled Maintenance\",\n      \"description\": \"reprehend\",\n      \"duration\": 1600000000,\n      \"end\": 1600000000,\n      \"rrule\": \"FREQ=DAILY;INTERVAL=10;COUNT=5\",\n      \"timezone\": \"UTC\"\n    }\n  }\n}",
      "options": {
        "raw": {
          "headerFamily": "json",
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{baseUrl}}/api/v1/slo/correction",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v1",
        "slo",
        "correction"
      ]
    },
    "description": "Create an SLO Correction."
  },
  "response": [
    {
      "name": "OK",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"data\": {\n    \"type\": \"correction\",\n    \"attributes\": {\n      \"slo_id\": \"sloId\",\n      \"start\": 1600000000,\n      \"category\": \"Scheduled Maintenance\",\n      \"description\": \"reprehend\",\n      \"duration\": 1600000000,\n      \"end\": 1600000000,\n      \"rrule\": \"FREQ=DAILY;INTERVAL=10;COUNT=5\",\n      \"timezone\": \"UTC\"\n    }\n  }\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/slo/correction",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "slo",
            "correction"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"data\": {\n    \"attributes\": {\n      \"category\": \"Scheduled Maintenance\",\n      \"created_at\": 11806311,\n      \"creator\": {\n        \"email\": \"dolor nisi\",\n        \"handle\": \"la\",\n        \"name\": \"in quis est cillum\"\n      },\n      \"description\": \"nostrud amet ea exercitation\",\n      \"duration\": 3600,\n      \"end\": 30790629,\n      \"modified_at\": 77538107,\n      \"modifier\": {\n        \"email\": \"pariatur nisi minim reprehenderit\",\n        \"handle\": \"irure commodo\",\n        \"name\": \"veniam\"\n      },\n      \"rrule\": \"FREQ=DAILY;INTERVAL=10;COUNT=5\",\n      \"slo_id\": \"incididunt qui velit sunt labore\",\n      \"start\": -34398281,\n      \"timezone\": \"eu id\"\n    },\n    \"id\": \"enim qui\",\n    \"type\": \"correction\"\n  }\n}"
    },
    {
      "name": "Bad Request",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"data\": {\n    \"type\": \"correction\",\n    \"attributes\": {\n      \"slo_id\": \"sloId\",\n      \"start\": 1600000000,\n      \"category\": \"Scheduled Maintenance\",\n      \"description\": \"reprehend\",\n      \"duration\": 1600000000,\n      \"end\": 1600000000,\n      \"rrule\": \"FREQ=DAILY;INTERVAL=10;COUNT=5\",\n      \"timezone\": \"UTC\"\n    }\n  }\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/slo/correction",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "slo",
            "correction"
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"Bad Request\",\n    \"Bad Request\"\n  ]\n}"
    },
    {
      "name": "Forbidden",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"data\": {\n    \"type\": \"correction\",\n    \"attributes\": {\n      \"slo_id\": \"sloId\",\n      \"start\": 1600000000,\n      \"category\": \"Scheduled Maintenance\",\n      \"description\": \"reprehend\",\n      \"duration\": 1600000000,\n      \"end\": 1600000000,\n      \"rrule\": \"FREQ=DAILY;INTERVAL=10;COUNT=5\",\n      \"timezone\": \"UTC\"\n    }\n  }\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/slo/correction",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "slo",
            "correction"
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"Bad Request\",\n    \"Bad Request\"\n  ]\n}"
    },
    {
      "name": "SLO Not Found",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"data\": {\n    \"type\": \"correction\",\n    \"attributes\": {\n      \"slo_id\": \"sloId\",\n      \"start\": 1600000000,\n      \"category\": \"Scheduled Maintenance\",\n      \"description\": \"reprehend\",\n      \"duration\": 1600000000,\n      \"end\": 1600000000,\n      \"rrule\": \"FREQ=DAILY;INTERVAL=10;COUNT=5\",\n      \"timezone\": \"UTC\"\n    }\n  }\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/slo/correction",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "slo",
            "correction"
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"Bad Request\",\n    \"Bad Request\"\n  ]\n}"
    },
    {
      "name": "Too many requests",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"data\": {\n    \"type\": \"correction\",\n    \"attributes\": {\n      \"slo_id\": \"sloId\",\n      \"start\": 1600000000,\n      \"category\": \"Scheduled Maintenance\",\n      \"description\": \"reprehend\",\n      \"duration\": 1600000000,\n      \"end\": 1600000000,\n      \"rrule\": \"FREQ=DAILY;INTERVAL=10;COUNT=5\",\n      \"timezone\": \"UTC\"\n    }\n  }\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/slo/correction",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "slo",
            "correction"
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"Bad Request\",\n    \"Bad Request\"\n  ]\n}"
    }
  ]
}