Chilkat Online Tools

PowerBuilder / Datadog API Collection / Get a single service definition

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_QueryParams
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Instance_location
string ls_Keyword_location
string ls_Message
string ls_Name
string ls_V_type
string ls_Url
string ls_StrVal
string ls_Github_html_url
string ls_Ingested_schema_version
string ls_Ingestion_source
string ls_Last_modified_time
string ls_Origin
string ls_Origin_detail
string ls_Schema_version
string ls_Dd_service
string ls_Description
string ls_Display_name
string ls_Service_tier
string ls_V_Email
string ls_Slack
string ls_Pagerduty
string ls_Application
string ls_Team
string ls_Id
string ls_V_Type
integer i
integer li_Count_i

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

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_QueryParams = create oleobject
li_rc = loo_QueryParams.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_QueryParams.UpdateString("schema_version","v1")

loo_Http.SetRequestHeader("Accept","application/json")

loo_Resp = loo_Http.QuickRequestParams("GET","https://api.app.ddog-gov.com/api/v2/services/definitions/:service_name",loo_QueryParams)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_QueryParams
    return
end if

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_Resp.GetBodySb(loo_SbResponseBody)

loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Resp.Header
    Write-Debug "Failed."
    destroy loo_Resp
    destroy loo_Http
    destroy loo_QueryParams
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

destroy loo_Resp

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

// {
//   "data": {
//     "attributes": {
//       "meta": {
//         "github-html-url": "<string>",
//         "ingested-schema-version": "<string>",
//         "ingestion-source": "<string>",
//         "last-modified-time": "<string>",
//         "origin": "<string>",
//         "origin-detail": "<string>",
//         "warnings": [
//           {
//             "instance-location": "<string>",
//             "keyword-location": "<string>",
//             "message": "<string>"
//           },
//           {
//             "instance-location": "<string>",
//             "keyword-location": "<string>",
//             "message": "<string>"
//           }
//         ]
//       },
//       "schema": {
//         "schema-version": "v1",
//         "info": {
//           "dd-service": "<string>",
//           "description": "<string>",
//           "display-name": "<string>",
//           "service-tier": "<string>"
//         },
//         "contact": {
//           "email": "<email>",
//           "slack": "<string>"
//         },
//         "extensions": {
//           "iruree76": {},
//           "aliqua_0": {},
//           "ad_3": {}
//         },
//         "external-resources": [
//           {
//             "name": "<string>",
//             "type": "code",
//             "url": "<string>"
//           },
//           {
//             "name": "<string>",
//             "type": "repo",
//             "url": "<string>"
//           }
//         ],
//         "integrations": {
//           "pagerduty": "<string>"
//         },
//         "org": {
//           "application": "<string>",
//           "team": "<string>"
//         },
//         "tags": [
//           "<string>",
//           "<string>"
//         ]
//       }
//     },
//     "id": "<string>",
//     "type": "<string>"
//   }
// }

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

ls_Github_html_url = loo_JResp.StringOf("data.attributes.meta.github-html-url")
ls_Ingested_schema_version = loo_JResp.StringOf("data.attributes.meta.ingested-schema-version")
ls_Ingestion_source = loo_JResp.StringOf("data.attributes.meta.ingestion-source")
ls_Last_modified_time = loo_JResp.StringOf("data.attributes.meta.last-modified-time")
ls_Origin = loo_JResp.StringOf("data.attributes.meta.origin")
ls_Origin_detail = loo_JResp.StringOf("data.attributes.meta.origin-detail")
ls_Schema_version = loo_JResp.StringOf("data.attributes.schema.schema-version")
ls_Dd_service = loo_JResp.StringOf("data.attributes.schema.info.dd-service")
ls_Description = loo_JResp.StringOf("data.attributes.schema.info.description")
ls_Display_name = loo_JResp.StringOf("data.attributes.schema.info.display-name")
ls_Service_tier = loo_JResp.StringOf("data.attributes.schema.info.service-tier")
ls_V_Email = loo_JResp.StringOf("data.attributes.schema.contact.email")
ls_Slack = loo_JResp.StringOf("data.attributes.schema.contact.slack")
ls_Pagerduty = loo_JResp.StringOf("data.attributes.schema.integrations.pagerduty")
ls_Application = loo_JResp.StringOf("data.attributes.schema.org.application")
ls_Team = loo_JResp.StringOf("data.attributes.schema.org.team")
ls_Id = loo_JResp.StringOf("data.id")
ls_V_Type = loo_JResp.StringOf("data.type")
i = 0
li_Count_i = loo_JResp.SizeOfArray("data.attributes.meta.warnings")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Instance_location = loo_JResp.StringOf("data.attributes.meta.warnings[i].instance-location")
    ls_Keyword_location = loo_JResp.StringOf("data.attributes.meta.warnings[i].keyword-location")
    ls_Message = loo_JResp.StringOf("data.attributes.meta.warnings[i].message")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("data.attributes.schema.external-resources")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Name = loo_JResp.StringOf("data.attributes.schema.external-resources[i].name")
    ls_V_type = loo_JResp.StringOf("data.attributes.schema.external-resources[i].type")
    ls_Url = loo_JResp.StringOf("data.attributes.schema.external-resources[i].url")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("data.attributes.schema.tags")
do while i < li_Count_i
    loo_JResp.I = i
    ls_StrVal = loo_JResp.StringOf("data.attributes.schema.tags[i]")
    i = i + 1
loop


destroy loo_Http
destroy loo_QueryParams
destroy loo_SbResponseBody
destroy loo_JResp

Curl Command

curl -G -d "schema_version=v1"
	-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v2/services/definitions/:service_name

Postman Collection Item JSON

{
  "name": "Get a single service definition",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/services/definitions/:service_name?schema_version=v1",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "services",
        "definitions",
        ":service_name"
      ],
      "query": [
        {
          "key": "schema_version",
          "value": "v1",
          "description": "The schema version desired in the response."
        }
      ],
      "variable": [
        {
          "key": "service_name",
          "value": "<string>"
        }
      ]
    },
    "description": "Get a single service definition from the Datadog Service Catalog."
  },
  "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/services/definitions/:service_name?schema_version=v1",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "services",
            "definitions",
            ":service_name"
          ],
          "query": [
            {
              "key": "schema_version",
              "value": "v1",
              "description": "The schema version desired in the response."
            }
          ],
          "variable": [
            {
              "key": "service_name"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"data\": {\n    \"attributes\": {\n      \"meta\": {\n        \"github-html-url\": \"<string>\",\n        \"ingested-schema-version\": \"<string>\",\n        \"ingestion-source\": \"<string>\",\n        \"last-modified-time\": \"<string>\",\n        \"origin\": \"<string>\",\n        \"origin-detail\": \"<string>\",\n        \"warnings\": [\n          {\n            \"instance-location\": \"<string>\",\n            \"keyword-location\": \"<string>\",\n            \"message\": \"<string>\"\n          },\n          {\n            \"instance-location\": \"<string>\",\n            \"keyword-location\": \"<string>\",\n            \"message\": \"<string>\"\n          }\n        ]\n      },\n      \"schema\": {\n        \"schema-version\": \"v1\",\n        \"info\": {\n          \"dd-service\": \"<string>\",\n          \"description\": \"<string>\",\n          \"display-name\": \"<string>\",\n          \"service-tier\": \"<string>\"\n        },\n        \"contact\": {\n          \"email\": \"<email>\",\n          \"slack\": \"<string>\"\n        },\n        \"extensions\": {\n          \"iruree76\": {},\n          \"aliqua_0\": {},\n          \"ad_3\": {}\n        },\n        \"external-resources\": [\n          {\n            \"name\": \"<string>\",\n            \"type\": \"code\",\n            \"url\": \"<string>\"\n          },\n          {\n            \"name\": \"<string>\",\n            \"type\": \"repo\",\n            \"url\": \"<string>\"\n          }\n        ],\n        \"integrations\": {\n          \"pagerduty\": \"<string>\"\n        },\n        \"org\": {\n          \"application\": \"<string>\",\n          \"team\": \"<string>\"\n        },\n        \"tags\": [\n          \"<string>\",\n          \"<string>\"\n        ]\n      }\n    },\n    \"id\": \"<string>\",\n    \"type\": \"<string>\"\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/v2/services/definitions/:service_name?schema_version=v1",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "services",
            "definitions",
            ":service_name"
          ],
          "query": [
            {
              "key": "schema_version",
              "value": "v1",
              "description": "The schema version desired in the response."
            }
          ],
          "variable": [
            {
              "key": "service_name"
            }
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"<string>\",\n    \"<string>\"\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/services/definitions/:service_name?schema_version=v1",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "services",
            "definitions",
            ":service_name"
          ],
          "query": [
            {
              "key": "schema_version",
              "value": "v1",
              "description": "The schema version desired in the response."
            }
          ],
          "variable": [
            {
              "key": "service_name"
            }
          ]
        }
      },
      "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": "Not Found",
      "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/services/definitions/:service_name?schema_version=v1",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "services",
            "definitions",
            ":service_name"
          ],
          "query": [
            {
              "key": "schema_version",
              "value": "v1",
              "description": "The schema version desired in the response."
            }
          ],
          "variable": [
            {
              "key": "service_name"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"<string>\",\n    \"<string>\"\n  ]\n}"
    },
    {
      "name": "Conflict",
      "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/services/definitions/:service_name?schema_version=v1",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "services",
            "definitions",
            ":service_name"
          ],
          "query": [
            {
              "key": "schema_version",
              "value": "v1",
              "description": "The schema version desired in the response."
            }
          ],
          "variable": [
            {
              "key": "service_name"
            }
          ]
        }
      },
      "status": "Conflict",
      "code": 409,
      "_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/services/definitions/:service_name?schema_version=v1",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "services",
            "definitions",
            ":service_name"
          ],
          "query": [
            {
              "key": "schema_version",
              "value": "v1",
              "description": "The schema version desired in the response."
            }
          ],
          "variable": [
            {
              "key": "service_name"
            }
          ]
        }
      },
      "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}"
    }
  ]
}