"""
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));