Chilkat Online Tools

SQL Server / Datadog API Collection / Get an SLO correction for an SLO

Back to Collection Items

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Accept', 'application/json'

    DECLARE @sbResponseBody int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbResponseBody OUT

    EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://api.app.ddog-gov.com/api/v1/slo/correction/:slo_correction_id', @sbResponseBody
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @sbResponseBody
        RETURN
      END

    DECLARE @jResp int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @jResp OUT

    EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
    EXEC sp_OASetProperty @jResp, 'EmitCompact', 0


    PRINT 'Response Body:'
    EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
    PRINT @sTmp0

    DECLARE @respStatusCode int
    EXEC sp_OAGetProperty @http, 'LastStatus', @respStatusCode OUT

    PRINT 'Response Status Code = ' + @respStatusCode
    IF @respStatusCode >= 400
      BEGIN

        PRINT 'Response Header:'
        EXEC sp_OAGetProperty @http, 'LastHeader', @sTmp0 OUT
        PRINT @sTmp0

        PRINT 'Failed.'
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @sbResponseBody
        EXEC @hr = sp_OADestroy @jResp
        RETURN
      END

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

    DECLARE @Category nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Category OUT, 'data.attributes.category'
    DECLARE @Created_at int
    EXEC sp_OAMethod @jResp, 'IntOf', @Created_at OUT, 'data.attributes.created_at'
    DECLARE @v_Email nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @v_Email OUT, 'data.attributes.creator.email'
    DECLARE @Handle nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Handle OUT, 'data.attributes.creator.handle'
    DECLARE @Name nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Name OUT, 'data.attributes.creator.name'
    DECLARE @Description nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Description OUT, 'data.attributes.description'
    DECLARE @Duration int
    EXEC sp_OAMethod @jResp, 'IntOf', @Duration OUT, 'data.attributes.duration'
    DECLARE @v_End int
    EXEC sp_OAMethod @jResp, 'IntOf', @v_End OUT, 'data.attributes.end'
    DECLARE @Modified_at int
    EXEC sp_OAMethod @jResp, 'IntOf', @Modified_at OUT, 'data.attributes.modified_at'
    DECLARE @ModifierEmail nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @ModifierEmail OUT, 'data.attributes.modifier.email'
    DECLARE @ModifierHandle nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @ModifierHandle OUT, 'data.attributes.modifier.handle'
    DECLARE @ModifierName nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @ModifierName OUT, 'data.attributes.modifier.name'
    DECLARE @Rrule nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Rrule OUT, 'data.attributes.rrule'
    DECLARE @Slo_id nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Slo_id OUT, 'data.attributes.slo_id'
    DECLARE @Start int
    EXEC sp_OAMethod @jResp, 'IntOf', @Start OUT, 'data.attributes.start'
    DECLARE @Timezone nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Timezone OUT, 'data.attributes.timezone'
    DECLARE @Id nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Id OUT, 'data.id'
    DECLARE @v_Type nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @v_Type OUT, 'data.type'

    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @sbResponseBody
    EXEC @hr = sp_OADestroy @jResp


END
GO

Curl Command

curl -X GET
	-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v1/slo/correction/:slo_correction_id

Postman Collection Item JSON

{
  "name": "Get an SLO correction for an SLO",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v1/slo/correction/:slo_correction_id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v1",
        "slo",
        "correction",
        ":slo_correction_id"
      ],
      "variable": [
        {
          "key": "slo_correction_id",
          "value": "tempor Ut sed velit"
        }
      ]
    },
    "description": "Get an SLO correction."
  },
  "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/v1/slo/correction/:slo_correction_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "slo",
            "correction",
            ":slo_correction_id"
          ],
          "variable": [
            {
              "key": "slo_correction_id"
            }
          ]
        }
      },
      "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": "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/v1/slo/correction/:slo_correction_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "slo",
            "correction",
            ":slo_correction_id"
          ],
          "variable": [
            {
              "key": "slo_correction_id"
            }
          ]
        }
      },
      "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": "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/v1/slo/correction/:slo_correction_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "slo",
            "correction",
            ":slo_correction_id"
          ],
          "variable": [
            {
              "key": "slo_correction_id"
            }
          ]
        }
      },
      "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": "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/v1/slo/correction/:slo_correction_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "slo",
            "correction",
            ":slo_correction_id"
          ],
          "variable": [
            {
              "key": "slo_correction_id"
            }
          ]
        }
      },
      "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}"
    }
  ]
}