Les corrections de statut SLO vous permettent d’éviter que des périodes spécifiques n’aient un impact négatif sur la marge d’erreur et le statut de votre SLO. Vous pouvez utiliser la fonctionnalité de correction de statut à des fins diverses, notamment pour supprimer des périodes de maintenance prévues, des périodes en dehors des heures de travail ou d’autres périodes qui ne correspondent pas à de véritables problèmes. Consultez la section relative aux corrections de statut SLO pour en savoir plus.
// Create an SLO correction returns "OK" response
packagemainimport("context""encoding/json""fmt""os""time""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV1")funcmain(){// there is a valid "slo" in the system
SloData0ID:=os.Getenv("SLO_DATA_0_ID")body:=datadogV1.SLOCorrectionCreateRequest{Data:&datadogV1.SLOCorrectionCreateData{Attributes:&datadogV1.SLOCorrectionCreateRequestAttributes{Category:datadogV1.SLOCORRECTIONCATEGORY_SCHEDULED_MAINTENANCE,Description:datadog.PtrString("Example-Service-Level-Objective-Correction"),End:datadog.PtrInt64(time.Now().Add(time.Hour*1).Unix()),SloId:SloData0ID,Start:time.Now().Unix(),Timezone:datadog.PtrString("UTC"),},Type:datadogV1.SLOCORRECTIONTYPE_CORRECTION,},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV1.NewServiceLevelObjectiveCorrectionsApi(apiClient)resp,r,err:=api.CreateSLOCorrection(ctx,body)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `ServiceLevelObjectiveCorrectionsApi.CreateSLOCorrection`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `ServiceLevelObjectiveCorrectionsApi.CreateSLOCorrection`:\n%s\n",responseContent)}
// Create an SLO correction with rrule returns "OK" response
packagemainimport("context""encoding/json""fmt""os""time""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV1")funcmain(){// there is a valid "slo" in the system
SloData0ID:=os.Getenv("SLO_DATA_0_ID")body:=datadogV1.SLOCorrectionCreateRequest{Data:&datadogV1.SLOCorrectionCreateData{Attributes:&datadogV1.SLOCorrectionCreateRequestAttributes{Category:datadogV1.SLOCORRECTIONCATEGORY_SCHEDULED_MAINTENANCE,Description:datadog.PtrString("Example-Service-Level-Objective-Correction"),SloId:SloData0ID,Start:time.Now().Unix(),Duration:datadog.PtrInt64(3600),Rrule:datadog.PtrString("FREQ=DAILY;INTERVAL=10;COUNT=5"),Timezone:datadog.PtrString("UTC"),},Type:datadogV1.SLOCORRECTIONTYPE_CORRECTION,},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV1.NewServiceLevelObjectiveCorrectionsApi(apiClient)resp,r,err:=api.CreateSLOCorrection(ctx,body)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `ServiceLevelObjectiveCorrectionsApi.CreateSLOCorrection`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `ServiceLevelObjectiveCorrectionsApi.CreateSLOCorrection`:\n%s\n",responseContent)}
// Create an SLO correction returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v1.api.ServiceLevelObjectiveCorrectionsApi;importcom.datadog.api.client.v1.model.SLOCorrectionCategory;importcom.datadog.api.client.v1.model.SLOCorrectionCreateData;importcom.datadog.api.client.v1.model.SLOCorrectionCreateRequest;importcom.datadog.api.client.v1.model.SLOCorrectionCreateRequestAttributes;importcom.datadog.api.client.v1.model.SLOCorrectionResponse;importcom.datadog.api.client.v1.model.SLOCorrectionType;importjava.time.OffsetDateTime;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();ServiceLevelObjectiveCorrectionsApiapiInstance=newServiceLevelObjectiveCorrectionsApi(defaultClient);// there is a valid "slo" in the systemStringSLO_DATA_0_ID=System.getenv("SLO_DATA_0_ID");SLOCorrectionCreateRequestbody=newSLOCorrectionCreateRequest().data(newSLOCorrectionCreateData().attributes(newSLOCorrectionCreateRequestAttributes().category(SLOCorrectionCategory.SCHEDULED_MAINTENANCE).description("Example-Service-Level-Objective-Correction").end(OffsetDateTime.now().plusHours(1).toInstant().getEpochSecond()).sloId(SLO_DATA_0_ID).start(OffsetDateTime.now().toInstant().getEpochSecond()).timezone("UTC")).type(SLOCorrectionType.CORRECTION));try{SLOCorrectionResponseresult=apiInstance.createSLOCorrection(body);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling ServiceLevelObjectiveCorrectionsApi#createSLOCorrection");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// Create an SLO correction with rrule returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v1.api.ServiceLevelObjectiveCorrectionsApi;importcom.datadog.api.client.v1.model.SLOCorrectionCategory;importcom.datadog.api.client.v1.model.SLOCorrectionCreateData;importcom.datadog.api.client.v1.model.SLOCorrectionCreateRequest;importcom.datadog.api.client.v1.model.SLOCorrectionCreateRequestAttributes;importcom.datadog.api.client.v1.model.SLOCorrectionResponse;importcom.datadog.api.client.v1.model.SLOCorrectionType;importjava.time.OffsetDateTime;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();ServiceLevelObjectiveCorrectionsApiapiInstance=newServiceLevelObjectiveCorrectionsApi(defaultClient);// there is a valid "slo" in the systemStringSLO_DATA_0_ID=System.getenv("SLO_DATA_0_ID");SLOCorrectionCreateRequestbody=newSLOCorrectionCreateRequest().data(newSLOCorrectionCreateData().attributes(newSLOCorrectionCreateRequestAttributes().category(SLOCorrectionCategory.SCHEDULED_MAINTENANCE).description("Example-Service-Level-Objective-Correction").sloId(SLO_DATA_0_ID).start(OffsetDateTime.now().toInstant().getEpochSecond()).duration(3600L).rrule("FREQ=DAILY;INTERVAL=10;COUNT=5").timezone("UTC")).type(SLOCorrectionType.CORRECTION));try{SLOCorrectionResponseresult=apiInstance.createSLOCorrection(body);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling ServiceLevelObjectiveCorrectionsApi#createSLOCorrection");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
"""
Create an SLO correction returns "OK" response
"""fromdatetimeimportdatetimefromdateutil.relativedeltaimportrelativedeltafromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v1.api.service_level_objective_corrections_apiimportServiceLevelObjectiveCorrectionsApifromdatadog_api_client.v1.model.slo_correction_categoryimportSLOCorrectionCategoryfromdatadog_api_client.v1.model.slo_correction_create_dataimportSLOCorrectionCreateDatafromdatadog_api_client.v1.model.slo_correction_create_requestimportSLOCorrectionCreateRequestfromdatadog_api_client.v1.model.slo_correction_create_request_attributesimportSLOCorrectionCreateRequestAttributesfromdatadog_api_client.v1.model.slo_correction_typeimportSLOCorrectionType# there is a valid "slo" in the systemSLO_DATA_0_ID=environ["SLO_DATA_0_ID"]body=SLOCorrectionCreateRequest(data=SLOCorrectionCreateData(attributes=SLOCorrectionCreateRequestAttributes(category=SLOCorrectionCategory.SCHEDULED_MAINTENANCE,description="Example-Service-Level-Objective-Correction",end=int((datetime.now()+relativedelta(hours=1)).timestamp()),slo_id=SLO_DATA_0_ID,start=int(datetime.now().timestamp()),timezone="UTC",),type=SLOCorrectionType.CORRECTION,),)configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=ServiceLevelObjectiveCorrectionsApi(api_client)response=api_instance.create_slo_correction(body=body)print(response)
"""
Create an SLO correction with rrule returns "OK" response
"""fromdatetimeimportdatetimefromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v1.api.service_level_objective_corrections_apiimportServiceLevelObjectiveCorrectionsApifromdatadog_api_client.v1.model.slo_correction_categoryimportSLOCorrectionCategoryfromdatadog_api_client.v1.model.slo_correction_create_dataimportSLOCorrectionCreateDatafromdatadog_api_client.v1.model.slo_correction_create_requestimportSLOCorrectionCreateRequestfromdatadog_api_client.v1.model.slo_correction_create_request_attributesimportSLOCorrectionCreateRequestAttributesfromdatadog_api_client.v1.model.slo_correction_typeimportSLOCorrectionType# there is a valid "slo" in the systemSLO_DATA_0_ID=environ["SLO_DATA_0_ID"]body=SLOCorrectionCreateRequest(data=SLOCorrectionCreateData(attributes=SLOCorrectionCreateRequestAttributes(category=SLOCorrectionCategory.SCHEDULED_MAINTENANCE,description="Example-Service-Level-Objective-Correction",slo_id=SLO_DATA_0_ID,start=int(datetime.now().timestamp()),duration=3600,rrule="FREQ=DAILY;INTERVAL=10;COUNT=5",timezone="UTC",),type=SLOCorrectionType.CORRECTION,),)configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=ServiceLevelObjectiveCorrectionsApi(api_client)response=api_instance.create_slo_correction(body=body)print(response)
# Create an SLO correction returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V1::ServiceLevelObjectiveCorrectionsAPI.new# there is a valid "slo" in the systemSLO_DATA_0_ID=ENV["SLO_DATA_0_ID"]body=DatadogAPIClient::V1::SLOCorrectionCreateRequest.new({data:DatadogAPIClient::V1::SLOCorrectionCreateData.new({attributes:DatadogAPIClient::V1::SLOCorrectionCreateRequestAttributes.new({category:DatadogAPIClient::V1::SLOCorrectionCategory::SCHEDULED_MAINTENANCE,description:"Example-Service-Level-Objective-Correction",_end:(Time.now+1*3600).to_i,slo_id:SLO_DATA_0_ID,start:Time.now.to_i,timezone:"UTC",}),type:DatadogAPIClient::V1::SLOCorrectionType::CORRECTION,}),})papi_instance.create_slo_correction(body)
# Create an SLO correction with rrule returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V1::ServiceLevelObjectiveCorrectionsAPI.new# there is a valid "slo" in the systemSLO_DATA_0_ID=ENV["SLO_DATA_0_ID"]body=DatadogAPIClient::V1::SLOCorrectionCreateRequest.new({data:DatadogAPIClient::V1::SLOCorrectionCreateData.new({attributes:DatadogAPIClient::V1::SLOCorrectionCreateRequestAttributes.new({category:DatadogAPIClient::V1::SLOCorrectionCategory::SCHEDULED_MAINTENANCE,description:"Example-Service-Level-Objective-Correction",slo_id:SLO_DATA_0_ID,start:Time.now.to_i,duration:3600,rrule:"FREQ=DAILY;INTERVAL=10;COUNT=5",timezone:"UTC",}),type:DatadogAPIClient::V1::SLOCorrectionType::CORRECTION,}),})papi_instance.create_slo_correction(body)
// Create an SLO correction returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV1::api_service_level_objective_corrections::ServiceLevelObjectiveCorrectionsAPI;usedatadog_api_client::datadogV1::model::SLOCorrectionCategory;usedatadog_api_client::datadogV1::model::SLOCorrectionCreateData;usedatadog_api_client::datadogV1::model::SLOCorrectionCreateRequest;usedatadog_api_client::datadogV1::model::SLOCorrectionCreateRequestAttributes;usedatadog_api_client::datadogV1::model::SLOCorrectionType;#[tokio::main]asyncfnmain(){// there is a valid "slo" in the system
letslo_data_0_id=std::env::var("SLO_DATA_0_ID").unwrap();letbody=SLOCorrectionCreateRequest::new().data(SLOCorrectionCreateData::new(SLOCorrectionType::CORRECTION).attributes(SLOCorrectionCreateRequestAttributes::new(SLOCorrectionCategory::SCHEDULED_MAINTENANCE,slo_data_0_id.clone(),1636629071,).description("Example-Service-Level-Objective-Correction".to_string()).end(1636632671).timezone("UTC".to_string()),),);letconfiguration=datadog::Configuration::new();letapi=ServiceLevelObjectiveCorrectionsAPI::with_config(configuration);letresp=api.create_slo_correction(body).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
// Create an SLO correction with rrule returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV1::api_service_level_objective_corrections::ServiceLevelObjectiveCorrectionsAPI;usedatadog_api_client::datadogV1::model::SLOCorrectionCategory;usedatadog_api_client::datadogV1::model::SLOCorrectionCreateData;usedatadog_api_client::datadogV1::model::SLOCorrectionCreateRequest;usedatadog_api_client::datadogV1::model::SLOCorrectionCreateRequestAttributes;usedatadog_api_client::datadogV1::model::SLOCorrectionType;#[tokio::main]asyncfnmain(){// there is a valid "slo" in the system
letslo_data_0_id=std::env::var("SLO_DATA_0_ID").unwrap();letbody=SLOCorrectionCreateRequest::new().data(SLOCorrectionCreateData::new(SLOCorrectionType::CORRECTION).attributes(SLOCorrectionCreateRequestAttributes::new(SLOCorrectionCategory::SCHEDULED_MAINTENANCE,slo_data_0_id.clone(),1636629071,).description("Example-Service-Level-Objective-Correction".to_string()).duration(3600).rrule("FREQ=DAILY;INTERVAL=10;COUNT=5".to_string()).timezone("UTC".to_string()),),);letconfiguration=datadog::Configuration::new();letapi=ServiceLevelObjectiveCorrectionsAPI::with_config(configuration);letresp=api.create_slo_correction(body).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
/**
* Create an SLO correction returns "OK" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.ServiceLevelObjectiveCorrectionsApi(configuration);// there is a valid "slo" in the system
constSLO_DATA_0_ID=process.env.SLO_DATA_0_IDasstring;constparams: v1.ServiceLevelObjectiveCorrectionsApiCreateSLOCorrectionRequest={body:{data:{attributes:{category:"Scheduled Maintenance",description:"Example-Service-Level-Objective-Correction",end: Math.round(newDate(newDate().getTime()+1*3600*1000).getTime()/1000),sloId: SLO_DATA_0_ID,start: Math.round(newDate().getTime()/1000),timezone:"UTC",},type:"correction",},},};apiInstance.createSLOCorrection(params).then((data: v1.SLOCorrectionResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
/**
* Create an SLO correction with rrule returns "OK" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.ServiceLevelObjectiveCorrectionsApi(configuration);// there is a valid "slo" in the system
constSLO_DATA_0_ID=process.env.SLO_DATA_0_IDasstring;constparams: v1.ServiceLevelObjectiveCorrectionsApiCreateSLOCorrectionRequest={body:{data:{attributes:{category:"Scheduled Maintenance",description:"Example-Service-Level-Objective-Correction",sloId: SLO_DATA_0_ID,start: Math.round(newDate().getTime()/1000),duration: 3600,rrule:"FREQ=DAILY;INTERVAL=10;COUNT=5",timezone:"UTC",},type:"correction",},},};apiInstance.createSLOCorrection(params).then((data: v1.SLOCorrectionResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
"""
Get all SLO corrections returns "OK" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v1.api.service_level_objective_corrections_apiimportServiceLevelObjectiveCorrectionsApiconfiguration=Configuration()withApiClient(configuration)asapi_client:api_instance=ServiceLevelObjectiveCorrectionsApi(api_client)response=api_instance.list_slo_correction(offset=1,limit=1,)print(response)
# Get all SLO corrections returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V1::ServiceLevelObjectiveCorrectionsAPI.newopts={offset:1,limit:1,}papi_instance.list_slo_correction(opts)
// Get all SLO corrections 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/datadogV1")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV1.NewServiceLevelObjectiveCorrectionsApi(apiClient)resp,r,err:=api.ListSLOCorrection(ctx,*datadogV1.NewListSLOCorrectionOptionalParameters().WithOffset(1).WithLimit(1))iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `ServiceLevelObjectiveCorrectionsApi.ListSLOCorrection`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `ServiceLevelObjectiveCorrectionsApi.ListSLOCorrection`:\n%s\n",responseContent)}
// Get all SLO corrections returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV1::api_service_level_objective_corrections::ListSLOCorrectionOptionalParams;usedatadog_api_client::datadogV1::api_service_level_objective_corrections::ServiceLevelObjectiveCorrectionsAPI;#[tokio::main]asyncfnmain(){letconfiguration=datadog::Configuration::new();letapi=ServiceLevelObjectiveCorrectionsAPI::with_config(configuration);letresp=api.list_slo_correction(ListSLOCorrectionOptionalParams::default().offset(1).limit(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 SLO corrections returns "OK" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.ServiceLevelObjectiveCorrectionsApi(configuration);constparams: v1.ServiceLevelObjectiveCorrectionsApiListSLOCorrectionRequest={offset: 1,limit: 1,};apiInstance.listSLOCorrection(params).then((data: v1.SLOCorrectionListResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
"""
Get an SLO correction for an SLO returns "OK" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v1.api.service_level_objective_corrections_apiimportServiceLevelObjectiveCorrectionsApi# there is a valid "correction" for "slo"CORRECTION_DATA_ID=environ["CORRECTION_DATA_ID"]configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=ServiceLevelObjectiveCorrectionsApi(api_client)response=api_instance.get_slo_correction(slo_correction_id=CORRECTION_DATA_ID,)print(response)
# Get an SLO correction for an SLO returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V1::ServiceLevelObjectiveCorrectionsAPI.new# there is a valid "correction" for "slo"CORRECTION_DATA_ID=ENV["CORRECTION_DATA_ID"]papi_instance.get_slo_correction(CORRECTION_DATA_ID)
// Get an SLO correction for an SLO 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/datadogV1")funcmain(){// there is a valid "correction" for "slo"
CorrectionDataID:=os.Getenv("CORRECTION_DATA_ID")ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV1.NewServiceLevelObjectiveCorrectionsApi(apiClient)resp,r,err:=api.GetSLOCorrection(ctx,CorrectionDataID)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `ServiceLevelObjectiveCorrectionsApi.GetSLOCorrection`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `ServiceLevelObjectiveCorrectionsApi.GetSLOCorrection`:\n%s\n",responseContent)}
// Get an SLO correction for an SLO returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v1.api.ServiceLevelObjectiveCorrectionsApi;importcom.datadog.api.client.v1.model.SLOCorrectionResponse;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();ServiceLevelObjectiveCorrectionsApiapiInstance=newServiceLevelObjectiveCorrectionsApi(defaultClient);// there is a valid "correction" for "slo"StringCORRECTION_DATA_ID=System.getenv("CORRECTION_DATA_ID");try{SLOCorrectionResponseresult=apiInstance.getSLOCorrection(CORRECTION_DATA_ID);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling ServiceLevelObjectiveCorrectionsApi#getSLOCorrection");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// Get an SLO correction for an SLO returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV1::api_service_level_objective_corrections::ServiceLevelObjectiveCorrectionsAPI;#[tokio::main]asyncfnmain(){// there is a valid "correction" for "slo"
letcorrection_data_id=std::env::var("CORRECTION_DATA_ID").unwrap();letconfiguration=datadog::Configuration::new();letapi=ServiceLevelObjectiveCorrectionsAPI::with_config(configuration);letresp=api.get_slo_correction(correction_data_id.clone()).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="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* Get an SLO correction for an SLO returns "OK" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.ServiceLevelObjectiveCorrectionsApi(configuration);// there is a valid "correction" for "slo"
constCORRECTION_DATA_ID=process.env.CORRECTION_DATA_IDasstring;constparams: v1.ServiceLevelObjectiveCorrectionsApiGetSLOCorrectionRequest={sloCorrectionId: CORRECTION_DATA_ID,};apiInstance.getSLOCorrection(params).then((data: v1.SLOCorrectionResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
// Update an SLO correction returns "OK" response
packagemainimport("context""encoding/json""fmt""os""time""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV1")funcmain(){// there is a valid "correction" for "slo"
CorrectionDataID:=os.Getenv("CORRECTION_DATA_ID")body:=datadogV1.SLOCorrectionUpdateRequest{Data:&datadogV1.SLOCorrectionUpdateData{Attributes:&datadogV1.SLOCorrectionUpdateRequestAttributes{Category:datadogV1.SLOCORRECTIONCATEGORY_DEPLOYMENT.Ptr(),Description:datadog.PtrString("Example-Service-Level-Objective-Correction"),End:datadog.PtrInt64(time.Now().Add(time.Hour*1).Unix()),Start:datadog.PtrInt64(time.Now().Unix()),Timezone:datadog.PtrString("UTC"),},Type:datadogV1.SLOCORRECTIONTYPE_CORRECTION.Ptr(),},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV1.NewServiceLevelObjectiveCorrectionsApi(apiClient)resp,r,err:=api.UpdateSLOCorrection(ctx,CorrectionDataID,body)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `ServiceLevelObjectiveCorrectionsApi.UpdateSLOCorrection`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `ServiceLevelObjectiveCorrectionsApi.UpdateSLOCorrection`:\n%s\n",responseContent)}
// Update an SLO correction returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v1.api.ServiceLevelObjectiveCorrectionsApi;importcom.datadog.api.client.v1.model.SLOCorrectionCategory;importcom.datadog.api.client.v1.model.SLOCorrectionResponse;importcom.datadog.api.client.v1.model.SLOCorrectionType;importcom.datadog.api.client.v1.model.SLOCorrectionUpdateData;importcom.datadog.api.client.v1.model.SLOCorrectionUpdateRequest;importcom.datadog.api.client.v1.model.SLOCorrectionUpdateRequestAttributes;importjava.time.OffsetDateTime;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();ServiceLevelObjectiveCorrectionsApiapiInstance=newServiceLevelObjectiveCorrectionsApi(defaultClient);// there is a valid "correction" for "slo"StringCORRECTION_DATA_ID=System.getenv("CORRECTION_DATA_ID");SLOCorrectionUpdateRequestbody=newSLOCorrectionUpdateRequest().data(newSLOCorrectionUpdateData().attributes(newSLOCorrectionUpdateRequestAttributes().category(SLOCorrectionCategory.DEPLOYMENT).description("Example-Service-Level-Objective-Correction").end(OffsetDateTime.now().plusHours(1).toInstant().getEpochSecond()).start(OffsetDateTime.now().toInstant().getEpochSecond()).timezone("UTC")).type(SLOCorrectionType.CORRECTION));try{SLOCorrectionResponseresult=apiInstance.updateSLOCorrection(CORRECTION_DATA_ID,body);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling ServiceLevelObjectiveCorrectionsApi#updateSLOCorrection");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
"""
Update an SLO correction returns "OK" response
"""fromdatetimeimportdatetimefromdateutil.relativedeltaimportrelativedeltafromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v1.api.service_level_objective_corrections_apiimportServiceLevelObjectiveCorrectionsApifromdatadog_api_client.v1.model.slo_correction_categoryimportSLOCorrectionCategoryfromdatadog_api_client.v1.model.slo_correction_typeimportSLOCorrectionTypefromdatadog_api_client.v1.model.slo_correction_update_dataimportSLOCorrectionUpdateDatafromdatadog_api_client.v1.model.slo_correction_update_requestimportSLOCorrectionUpdateRequestfromdatadog_api_client.v1.model.slo_correction_update_request_attributesimportSLOCorrectionUpdateRequestAttributes# there is a valid "correction" for "slo"CORRECTION_DATA_ID=environ["CORRECTION_DATA_ID"]body=SLOCorrectionUpdateRequest(data=SLOCorrectionUpdateData(attributes=SLOCorrectionUpdateRequestAttributes(category=SLOCorrectionCategory.DEPLOYMENT,description="Example-Service-Level-Objective-Correction",end=int((datetime.now()+relativedelta(hours=1)).timestamp()),start=int(datetime.now().timestamp()),timezone="UTC",),type=SLOCorrectionType.CORRECTION,),)configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=ServiceLevelObjectiveCorrectionsApi(api_client)response=api_instance.update_slo_correction(slo_correction_id=CORRECTION_DATA_ID,body=body)print(response)
# Update an SLO correction returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V1::ServiceLevelObjectiveCorrectionsAPI.new# there is a valid "correction" for "slo"CORRECTION_DATA_ID=ENV["CORRECTION_DATA_ID"]body=DatadogAPIClient::V1::SLOCorrectionUpdateRequest.new({data:DatadogAPIClient::V1::SLOCorrectionUpdateData.new({attributes:DatadogAPIClient::V1::SLOCorrectionUpdateRequestAttributes.new({category:DatadogAPIClient::V1::SLOCorrectionCategory::DEPLOYMENT,description:"Example-Service-Level-Objective-Correction",_end:(Time.now+1*3600).to_i,start:Time.now.to_i,timezone:"UTC",}),type:DatadogAPIClient::V1::SLOCorrectionType::CORRECTION,}),})papi_instance.update_slo_correction(CORRECTION_DATA_ID,body)
// Update an SLO correction returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV1::api_service_level_objective_corrections::ServiceLevelObjectiveCorrectionsAPI;usedatadog_api_client::datadogV1::model::SLOCorrectionCategory;usedatadog_api_client::datadogV1::model::SLOCorrectionType;usedatadog_api_client::datadogV1::model::SLOCorrectionUpdateData;usedatadog_api_client::datadogV1::model::SLOCorrectionUpdateRequest;usedatadog_api_client::datadogV1::model::SLOCorrectionUpdateRequestAttributes;#[tokio::main]asyncfnmain(){// there is a valid "correction" for "slo"
letcorrection_data_id=std::env::var("CORRECTION_DATA_ID").unwrap();letbody=SLOCorrectionUpdateRequest::new().data(SLOCorrectionUpdateData::new().attributes(SLOCorrectionUpdateRequestAttributes::new().category(SLOCorrectionCategory::DEPLOYMENT).description("Example-Service-Level-Objective-Correction".to_string()).end(1636632671).start(1636629071).timezone("UTC".to_string()),).type_(SLOCorrectionType::CORRECTION),);letconfiguration=datadog::Configuration::new();letapi=ServiceLevelObjectiveCorrectionsAPI::with_config(configuration);letresp=api.update_slo_correction(correction_data_id.clone(),body).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="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* Update an SLO correction returns "OK" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.ServiceLevelObjectiveCorrectionsApi(configuration);// there is a valid "correction" for "slo"
constCORRECTION_DATA_ID=process.env.CORRECTION_DATA_IDasstring;constparams: v1.ServiceLevelObjectiveCorrectionsApiUpdateSLOCorrectionRequest={body:{data:{attributes:{category:"Deployment",description:"Example-Service-Level-Objective-Correction",end: Math.round(newDate(newDate().getTime()+1*3600*1000).getTime()/1000),start: Math.round(newDate().getTime()/1000),timezone:"UTC",},type:"correction",},},sloCorrectionId: CORRECTION_DATA_ID,};apiInstance.updateSLOCorrection(params).then((data: v1.SLOCorrectionResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* Delete an SLO correction returns "OK" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.ServiceLevelObjectiveCorrectionsApi(configuration);constparams: v1.ServiceLevelObjectiveCorrectionsApiDeleteSLOCorrectionRequest={sloCorrectionId:"slo_correction_id",};apiInstance.deleteSLOCorrection(params).then((data: any)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));