API to create, update, retrieve and delete service definitions.
Note: Service Catalog v3.0 schema has new API endpoints documented under Software Catalog. Use the following Service Definition endpoints for v2.2 and earlier.
"""
Get all service definitions returns "OK" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.service_definition_apiimportServiceDefinitionApifromdatadog_api_client.v2.model.service_definition_schema_versionsimportServiceDefinitionSchemaVersionsconfiguration=Configuration()withApiClient(configuration)asapi_client:api_instance=ServiceDefinitionApi(api_client)response=api_instance.list_service_definitions(schema_version=ServiceDefinitionSchemaVersions.V2_1,)print(response)
# Get all service definitions returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::ServiceDefinitionAPI.newopts={schema_version:ServiceDefinitionSchemaVersions::V2_1,}papi_instance.list_service_definitions(opts)
// Get all service definitions returns "OK" response
packagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewServiceDefinitionApi(apiClient)resp,r,err:=api.ListServiceDefinitions(ctx,*datadogV2.NewListServiceDefinitionsOptionalParameters().WithSchemaVersion(datadogV2.SERVICEDEFINITIONSCHEMAVERSIONS_V2_1))iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `ServiceDefinitionApi.ListServiceDefinitions`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `ServiceDefinitionApi.ListServiceDefinitions`:\n%s\n",responseContent)}
// Get all service definitions returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.ServiceDefinitionApi;importcom.datadog.api.client.v2.api.ServiceDefinitionApi.ListServiceDefinitionsOptionalParameters;importcom.datadog.api.client.v2.model.ServiceDefinitionSchemaVersions;importcom.datadog.api.client.v2.model.ServiceDefinitionsListResponse;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();ServiceDefinitionApiapiInstance=newServiceDefinitionApi(defaultClient);try{ServiceDefinitionsListResponseresult=apiInstance.listServiceDefinitions(newListServiceDefinitionsOptionalParameters().schemaVersion(ServiceDefinitionSchemaVersions.V2_1));System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling ServiceDefinitionApi#listServiceDefinitions");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// Get all service definitions returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_service_definition::ListServiceDefinitionsOptionalParams;usedatadog_api_client::datadogV2::api_service_definition::ServiceDefinitionAPI;usedatadog_api_client::datadogV2::model::ServiceDefinitionSchemaVersions;#[tokio::main]asyncfnmain(){letconfiguration=datadog::Configuration::new();letapi=ServiceDefinitionAPI::with_config(configuration);letresp=api.list_service_definitions(ListServiceDefinitionsOptionalParams::default().schema_version(ServiceDefinitionSchemaVersions::V2_1),).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Get all service definitions returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.ServiceDefinitionApi(configuration);constparams: v2.ServiceDefinitionApiListServiceDefinitionsRequest={schemaVersion:"v2.1",};apiInstance.listServiceDefinitions(params).then((data: v2.ServiceDefinitionsListResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
# Create or update service definition using schema v2 returns "CREATED" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::ServiceDefinitionAPI.newbody=DatadogAPIClient::V2::ServiceDefinitionV2.new({contacts:[DatadogAPIClient::V2::ServiceDefinitionV2Email.new({contact:"contact@datadoghq.com",name:"Team Email",type:DatadogAPIClient::V2::ServiceDefinitionV2EmailType::EMAIL,}),],dd_service:"service-exampleservicedefinition",dd_team:"my-team",docs:[DatadogAPIClient::V2::ServiceDefinitionV2Doc.new({name:"Architecture",provider:"google drive",url:"https://gdrive/mydoc",}),],extensions:{"myorgextension":"extensionvalue",},integrations:DatadogAPIClient::V2::ServiceDefinitionV2Integrations.new({opsgenie:DatadogAPIClient::V2::ServiceDefinitionV2Opsgenie.new({region:DatadogAPIClient::V2::ServiceDefinitionV2OpsgenieRegion::US,service_url:"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000",}),pagerduty:"https://my-org.pagerduty.com/service-directory/PMyService",}),links:[DatadogAPIClient::V2::ServiceDefinitionV2Link.new({name:"Runbook",type:DatadogAPIClient::V2::ServiceDefinitionV2LinkType::RUNBOOK,url:"https://my-runbook",}),],repos:[DatadogAPIClient::V2::ServiceDefinitionV2Repo.new({name:"Source Code",provider:"GitHub",url:"https://github.com/DataDog/schema",}),],schema_version:DatadogAPIClient::V2::ServiceDefinitionV2Version::V2,tags:["my:tag","service:tag",],team:"my-team",})papi_instance.create_or_update_service_definitions(body)
# Create or update service definition using schema v2-1 returns "CREATED" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::ServiceDefinitionAPI.newbody=DatadogAPIClient::V2::ServiceDefinitionV2Dot1.new({contacts:[DatadogAPIClient::V2::ServiceDefinitionV2Dot1Email.new({contact:"contact@datadoghq.com",name:"Team Email",type:DatadogAPIClient::V2::ServiceDefinitionV2Dot1EmailType::EMAIL,}),],dd_service:"service-exampleservicedefinition",extensions:{"myorgextension":"extensionvalue",},integrations:DatadogAPIClient::V2::ServiceDefinitionV2Dot1Integrations.new({opsgenie:DatadogAPIClient::V2::ServiceDefinitionV2Dot1Opsgenie.new({region:DatadogAPIClient::V2::ServiceDefinitionV2Dot1OpsgenieRegion::US,service_url:"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000",}),pagerduty:DatadogAPIClient::V2::ServiceDefinitionV2Dot1Pagerduty.new({service_url:"https://my-org.pagerduty.com/service-directory/PMyService",}),}),links:[DatadogAPIClient::V2::ServiceDefinitionV2Dot1Link.new({name:"Runbook",type:DatadogAPIClient::V2::ServiceDefinitionV2Dot1LinkType::RUNBOOK,url:"https://my-runbook",}),DatadogAPIClient::V2::ServiceDefinitionV2Dot1Link.new({name:"Source Code",type:DatadogAPIClient::V2::ServiceDefinitionV2Dot1LinkType::REPO,provider:"GitHub",url:"https://github.com/DataDog/schema",}),DatadogAPIClient::V2::ServiceDefinitionV2Dot1Link.new({name:"Architecture",type:DatadogAPIClient::V2::ServiceDefinitionV2Dot1LinkType::DOC,provider:"Gigoogle drivetHub",url:"https://my-runbook",}),],schema_version:DatadogAPIClient::V2::ServiceDefinitionV2Dot1Version::V2_1,tags:["my:tag","service:tag",],team:"my-team",})papi_instance.create_or_update_service_definitions(body)
# Create or update service definition using schema v2-2 returns "CREATED" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::ServiceDefinitionAPI.newbody=DatadogAPIClient::V2::ServiceDefinitionV2Dot2.new({contacts:[DatadogAPIClient::V2::ServiceDefinitionV2Dot2Contact.new({contact:"contact@datadoghq.com",name:"Team Email",type:"email",}),],dd_service:"service-exampleservicedefinition",extensions:{"myorgextension":"extensionvalue",},integrations:DatadogAPIClient::V2::ServiceDefinitionV2Dot2Integrations.new({opsgenie:DatadogAPIClient::V2::ServiceDefinitionV2Dot2Opsgenie.new({region:DatadogAPIClient::V2::ServiceDefinitionV2Dot2OpsgenieRegion::US,service_url:"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000",}),pagerduty:DatadogAPIClient::V2::ServiceDefinitionV2Dot2Pagerduty.new({service_url:"https://my-org.pagerduty.com/service-directory/PMyService",}),}),links:[DatadogAPIClient::V2::ServiceDefinitionV2Dot2Link.new({name:"Runbook",type:"runbook",url:"https://my-runbook",}),DatadogAPIClient::V2::ServiceDefinitionV2Dot2Link.new({name:"Source Code",type:"repo",provider:"GitHub",url:"https://github.com/DataDog/schema",}),DatadogAPIClient::V2::ServiceDefinitionV2Dot2Link.new({name:"Architecture",type:"doc",provider:"Gigoogle drivetHub",url:"https://my-runbook",}),],schema_version:DatadogAPIClient::V2::ServiceDefinitionV2Dot2Version::V2_2,tags:["my:tag","service:tag",],team:"my-team",})papi_instance.create_or_update_service_definitions(body)
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Create or update service definition using schema v2 returns "CREATED" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.ServiceDefinitionApi(configuration);constparams: v2.ServiceDefinitionApiCreateOrUpdateServiceDefinitionsRequest={body:{contacts:[{contact:"contact@datadoghq.com",name:"Team Email",type:"email",},],ddService:"service-exampleservicedefinition",ddTeam:"my-team",docs:[{name:"Architecture",provider:"google drive",url:"https://gdrive/mydoc",},],extensions:{myorgextension:"extensionvalue",},integrations:{opsgenie:{region:"US",serviceUrl:"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000",},pagerduty:"https://my-org.pagerduty.com/service-directory/PMyService",},links:[{name:"Runbook",type:"runbook",url:"https://my-runbook",},],repos:[{name:"Source Code",provider:"GitHub",url:"https://github.com/DataDog/schema",},],schemaVersion:"v2",tags:["my:tag","service:tag"],team:"my-team",},};apiInstance.createOrUpdateServiceDefinitions(params).then((data: v2.ServiceDefinitionCreateResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
/**
* Create or update service definition using schema v2-1 returns "CREATED" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.ServiceDefinitionApi(configuration);constparams: v2.ServiceDefinitionApiCreateOrUpdateServiceDefinitionsRequest={body:{contacts:[{contact:"contact@datadoghq.com",name:"Team Email",type:"email",},],ddService:"service-exampleservicedefinition",extensions:{myorgextension:"extensionvalue",},integrations:{opsgenie:{region:"US",serviceUrl:"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000",},pagerduty:{serviceUrl:"https://my-org.pagerduty.com/service-directory/PMyService",},},links:[{name:"Runbook",type:"runbook",url:"https://my-runbook",},{name:"Source Code",type:"repo",provider:"GitHub",url:"https://github.com/DataDog/schema",},{name:"Architecture",type:"doc",provider:"Gigoogle drivetHub",url:"https://my-runbook",},],schemaVersion:"v2.1",tags:["my:tag","service:tag"],team:"my-team",},};apiInstance.createOrUpdateServiceDefinitions(params).then((data: v2.ServiceDefinitionCreateResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
/**
* Create or update service definition using schema v2-2 returns "CREATED" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.ServiceDefinitionApi(configuration);constparams: v2.ServiceDefinitionApiCreateOrUpdateServiceDefinitionsRequest={body:{contacts:[{contact:"contact@datadoghq.com",name:"Team Email",type:"email",},],ddService:"service-exampleservicedefinition",extensions:{myorgextension:"extensionvalue",},integrations:{opsgenie:{region:"US",serviceUrl:"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000",},pagerduty:{serviceUrl:"https://my-org.pagerduty.com/service-directory/PMyService",},},links:[{name:"Runbook",type:"runbook",url:"https://my-runbook",},{name:"Source Code",type:"repo",provider:"GitHub",url:"https://github.com/DataDog/schema",},{name:"Architecture",type:"doc",provider:"Gigoogle drivetHub",url:"https://my-runbook",},],schemaVersion:"v2.2",tags:["my:tag","service:tag"],team:"my-team",},};apiInstance.createOrUpdateServiceDefinitions(params).then((data: v2.ServiceDefinitionCreateResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
"""
Get a single service definition returns "OK" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.service_definition_apiimportServiceDefinitionApifromdatadog_api_client.v2.model.service_definition_schema_versionsimportServiceDefinitionSchemaVersionsconfiguration=Configuration()withApiClient(configuration)asapi_client:api_instance=ServiceDefinitionApi(api_client)response=api_instance.get_service_definition(service_name="service-definition-test",schema_version=ServiceDefinitionSchemaVersions.V2_1,)print(response)
# Get a single service definition returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::ServiceDefinitionAPI.newopts={schema_version:ServiceDefinitionSchemaVersions::V2_1,}papi_instance.get_service_definition("service-definition-test",opts)
// Get a single service definition returns "OK" response
packagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewServiceDefinitionApi(apiClient)resp,r,err:=api.GetServiceDefinition(ctx,"service-definition-test",*datadogV2.NewGetServiceDefinitionOptionalParameters().WithSchemaVersion(datadogV2.SERVICEDEFINITIONSCHEMAVERSIONS_V2_1))iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `ServiceDefinitionApi.GetServiceDefinition`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `ServiceDefinitionApi.GetServiceDefinition`:\n%s\n",responseContent)}
// Get a single service definition returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.ServiceDefinitionApi;importcom.datadog.api.client.v2.api.ServiceDefinitionApi.GetServiceDefinitionOptionalParameters;importcom.datadog.api.client.v2.model.ServiceDefinitionGetResponse;importcom.datadog.api.client.v2.model.ServiceDefinitionSchemaVersions;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();ServiceDefinitionApiapiInstance=newServiceDefinitionApi(defaultClient);try{ServiceDefinitionGetResponseresult=apiInstance.getServiceDefinition("service-definition-test",newGetServiceDefinitionOptionalParameters().schemaVersion(ServiceDefinitionSchemaVersions.V2_1));System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling ServiceDefinitionApi#getServiceDefinition");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// Get a single service definition returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_service_definition::GetServiceDefinitionOptionalParams;usedatadog_api_client::datadogV2::api_service_definition::ServiceDefinitionAPI;usedatadog_api_client::datadogV2::model::ServiceDefinitionSchemaVersions;#[tokio::main]asyncfnmain(){letconfiguration=datadog::Configuration::new();letapi=ServiceDefinitionAPI::with_config(configuration);letresp=api.get_service_definition("service-definition-test".to_string(),GetServiceDefinitionOptionalParams::default().schema_version(ServiceDefinitionSchemaVersions::V2_1),).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Get a single service definition returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.ServiceDefinitionApi(configuration);constparams: v2.ServiceDefinitionApiGetServiceDefinitionRequest={serviceName:"service-definition-test",schemaVersion:"v2.1",};apiInstance.getServiceDefinition(params).then((data: v2.ServiceDefinitionGetResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
"""
Delete a single service definition returns "OK" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.service_definition_apiimportServiceDefinitionApiconfiguration=Configuration()withApiClient(configuration)asapi_client:api_instance=ServiceDefinitionApi(api_client)api_instance.delete_service_definition(service_name="service-definition-test",)
# Delete a single service definition returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::ServiceDefinitionAPI.newapi_instance.delete_service_definition("service-definition-test")
// Delete a single service definition returns "OK" response
packagemainimport("context""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewServiceDefinitionApi(apiClient)r,err:=api.DeleteServiceDefinition(ctx,"service-definition-test")iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `ServiceDefinitionApi.DeleteServiceDefinition`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}}
// Delete a single service definition returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.ServiceDefinitionApi;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();ServiceDefinitionApiapiInstance=newServiceDefinitionApi(defaultClient);try{apiInstance.deleteServiceDefinition("service-definition-test");}catch(ApiExceptione){System.err.println("Exception when calling ServiceDefinitionApi#deleteServiceDefinition");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// Delete a single service definition returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_service_definition::ServiceDefinitionAPI;#[tokio::main]asyncfnmain(){letconfiguration=datadog::Configuration::new();letapi=ServiceDefinitionAPI::with_config(configuration);letresp=api.delete_service_definition("service-definition-test".to_string()).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Delete a single service definition returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.ServiceDefinitionApi(configuration);constparams: v2.ServiceDefinitionApiDeleteServiceDefinitionRequest={serviceName:"service-definition-test",};apiInstance.deleteServiceDefinition(params).then((data: any)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));