SQL Server / Datadog API Collection / Get a single service definition
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
DECLARE @iTmp0 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
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
DECLARE @queryParams int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @queryParams OUT
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'schema_version', 'v1'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Accept', 'application/json'
DECLARE @resp int
EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://api.app.ddog-gov.com/api/v2/services/definitions/:service_name', @queryParams
EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
RETURN
END
DECLARE @sbResponseBody int
-- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @resp, 'GetBodySb', @success OUT, @sbResponseBody
DECLARE @jResp int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.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 @resp, 'StatusCode', @respStatusCode OUT
PRINT 'Response Status Code = ' + @respStatusCode
IF @respStatusCode >= 400
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @resp, 'Header', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Failed.'
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
RETURN
END
EXEC @hr = sp_OADestroy @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
DECLARE @instance_location nvarchar(4000)
DECLARE @keyword_location nvarchar(4000)
DECLARE @message nvarchar(4000)
DECLARE @name nvarchar(4000)
DECLARE @v_type nvarchar(4000)
DECLARE @url nvarchar(4000)
DECLARE @strVal nvarchar(4000)
DECLARE @Github_html_url nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Github_html_url OUT, 'data.attributes.meta.github-html-url'
DECLARE @Ingested_schema_version nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Ingested_schema_version OUT, 'data.attributes.meta.ingested-schema-version'
DECLARE @Ingestion_source nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Ingestion_source OUT, 'data.attributes.meta.ingestion-source'
DECLARE @Last_modified_time nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Last_modified_time OUT, 'data.attributes.meta.last-modified-time'
DECLARE @Origin nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Origin OUT, 'data.attributes.meta.origin'
DECLARE @Origin_detail nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Origin_detail OUT, 'data.attributes.meta.origin-detail'
DECLARE @Schema_version nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Schema_version OUT, 'data.attributes.schema.schema-version'
DECLARE @Dd_service nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Dd_service OUT, 'data.attributes.schema.info.dd-service'
DECLARE @Description nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Description OUT, 'data.attributes.schema.info.description'
DECLARE @Display_name nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Display_name OUT, 'data.attributes.schema.info.display-name'
DECLARE @Service_tier nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Service_tier OUT, 'data.attributes.schema.info.service-tier'
DECLARE @v_Email nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @v_Email OUT, 'data.attributes.schema.contact.email'
DECLARE @Slack nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Slack OUT, 'data.attributes.schema.contact.slack'
DECLARE @Pagerduty nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Pagerduty OUT, 'data.attributes.schema.integrations.pagerduty'
DECLARE @Application nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Application OUT, 'data.attributes.schema.org.application'
DECLARE @Team nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Team OUT, 'data.attributes.schema.org.team'
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'
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'data.attributes.meta.warnings'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @instance_location OUT, 'data.attributes.meta.warnings[i].instance-location'
EXEC sp_OAMethod @jResp, 'StringOf', @keyword_location OUT, 'data.attributes.meta.warnings[i].keyword-location'
EXEC sp_OAMethod @jResp, 'StringOf', @message OUT, 'data.attributes.meta.warnings[i].message'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'data.attributes.schema.external-resources'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @name OUT, 'data.attributes.schema.external-resources[i].name'
EXEC sp_OAMethod @jResp, 'StringOf', @v_type OUT, 'data.attributes.schema.external-resources[i].type'
EXEC sp_OAMethod @jResp, 'StringOf', @url OUT, 'data.attributes.schema.external-resources[i].url'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'data.attributes.schema.tags'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'data.attributes.schema.tags[i]'
SELECT @i = @i + 1
END
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO
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}"
}
]
}