Update a notification rule for a user. The authenticated user must be the target user or have the on_call_admin permission
This endpoint requires the on_call_read permission.
引数
パスパラメーター
名前
種類
説明
user_id [required]
string
The user ID
rule_id [required]
string
The rule ID
クエリ文字列
名前
種類
説明
include
string
Comma-separated list of included relationships to be returned. Allowed values: channel.
// Update an On-Call notification rule for a user returns "OK" responsepackagemainimport("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(){// there is a valid "user" in the systemUserDataID:=os.Getenv("USER_DATA_ID")// there is a valid "oncall_email_notification_rule" in the systemOncallEmailNotificationRuleDataID:=os.Getenv("ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID")// there is a valid "oncall_email_notification_channel" in the systemOncallEmailNotificationChannelDataID:=os.Getenv("ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID")body:=datadogV2.UpdateOnCallNotificationRuleRequest{Data:datadogV2.UpdateOnCallNotificationRuleRequestData{Attributes:&datadogV2.UpdateOnCallNotificationRuleRequestAttributes{Category:datadogV2.ONCALLNOTIFICATIONRULECATEGORY_HIGH_URGENCY.Ptr(),DelayMinutes:datadog.PtrInt64(1),},Id:datadog.PtrString(OncallEmailNotificationRuleDataID),Relationships:&datadogV2.OnCallNotificationRuleRelationships{Channel:&datadogV2.OnCallNotificationRuleChannelRelationship{Data:datadogV2.OnCallNotificationRuleChannelRelationshipData{Id:datadog.PtrString(OncallEmailNotificationChannelDataID),Type:datadogV2.NOTIFICATIONCHANNELTYPE_NOTIFICATION_CHANNELS.Ptr(),},},},Type:datadogV2.ONCALLNOTIFICATIONRULETYPE_NOTIFICATION_RULES,},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewOnCallApi(apiClient)resp,r,err:=api.UpdateUserNotificationRule(ctx,UserDataID,OncallEmailNotificationRuleDataID,body,*datadogV2.NewUpdateUserNotificationRuleOptionalParameters().WithInclude("channel"))iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `OnCallApi.UpdateUserNotificationRule`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `OnCallApi.UpdateUserNotificationRule`:\n%s\n",responseContent)}
// Update an On-Call notification rule for a user returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.OnCallApi;importcom.datadog.api.client.v2.api.OnCallApi.UpdateUserNotificationRuleOptionalParameters;importcom.datadog.api.client.v2.model.NotificationChannelType;importcom.datadog.api.client.v2.model.OnCallNotificationRule;importcom.datadog.api.client.v2.model.OnCallNotificationRuleCategory;importcom.datadog.api.client.v2.model.OnCallNotificationRuleChannelRelationship;importcom.datadog.api.client.v2.model.OnCallNotificationRuleChannelRelationshipData;importcom.datadog.api.client.v2.model.OnCallNotificationRuleRelationships;importcom.datadog.api.client.v2.model.OnCallNotificationRuleType;importcom.datadog.api.client.v2.model.UpdateOnCallNotificationRuleRequest;importcom.datadog.api.client.v2.model.UpdateOnCallNotificationRuleRequestAttributes;importcom.datadog.api.client.v2.model.UpdateOnCallNotificationRuleRequestData;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();OnCallApiapiInstance=newOnCallApi(defaultClient);// there is a valid "user" in the systemStringUSER_DATA_ID=System.getenv("USER_DATA_ID");// there is a valid "oncall_email_notification_rule" in the systemStringONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID=System.getenv("ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID");// there is a valid "oncall_email_notification_channel" in the systemStringONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID=System.getenv("ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID");UpdateOnCallNotificationRuleRequestbody=newUpdateOnCallNotificationRuleRequest().data(newUpdateOnCallNotificationRuleRequestData().attributes(newUpdateOnCallNotificationRuleRequestAttributes().category(OnCallNotificationRuleCategory.HIGH_URGENCY).delayMinutes(1L)).id(ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID).relationships(newOnCallNotificationRuleRelationships().channel(newOnCallNotificationRuleChannelRelationship().data(newOnCallNotificationRuleChannelRelationshipData().id(ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID).type(NotificationChannelType.NOTIFICATION_CHANNELS)))).type(OnCallNotificationRuleType.NOTIFICATION_RULES));try{OnCallNotificationRuleresult=apiInstance.updateUserNotificationRule(USER_DATA_ID,ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID,body,newUpdateUserNotificationRuleOptionalParameters().include("channel"));System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling OnCallApi#updateUserNotificationRule");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
"""
Update an On-Call notification rule for a user returns "OK" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.on_call_apiimportOnCallApifromdatadog_api_client.v2.model.notification_channel_typeimportNotificationChannelTypefromdatadog_api_client.v2.model.on_call_notification_rule_categoryimportOnCallNotificationRuleCategoryfromdatadog_api_client.v2.model.on_call_notification_rule_channel_relationshipimport(OnCallNotificationRuleChannelRelationship,)fromdatadog_api_client.v2.model.on_call_notification_rule_channel_relationship_dataimport(OnCallNotificationRuleChannelRelationshipData,)fromdatadog_api_client.v2.model.on_call_notification_rule_relationshipsimportOnCallNotificationRuleRelationshipsfromdatadog_api_client.v2.model.on_call_notification_rule_typeimportOnCallNotificationRuleTypefromdatadog_api_client.v2.model.update_on_call_notification_rule_requestimportUpdateOnCallNotificationRuleRequestfromdatadog_api_client.v2.model.update_on_call_notification_rule_request_attributesimport(UpdateOnCallNotificationRuleRequestAttributes,)fromdatadog_api_client.v2.model.update_on_call_notification_rule_request_dataimport(UpdateOnCallNotificationRuleRequestData,)# there is a valid "user" in the systemUSER_DATA_ID=environ["USER_DATA_ID"]# there is a valid "oncall_email_notification_rule" in the systemONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID=environ["ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID"]# there is a valid "oncall_email_notification_channel" in the systemONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID=environ["ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID"]body=UpdateOnCallNotificationRuleRequest(data=UpdateOnCallNotificationRuleRequestData(attributes=UpdateOnCallNotificationRuleRequestAttributes(category=OnCallNotificationRuleCategory.HIGH_URGENCY,delay_minutes=1,),id=ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID,relationships=OnCallNotificationRuleRelationships(channel=OnCallNotificationRuleChannelRelationship(data=OnCallNotificationRuleChannelRelationshipData(id=ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID,type=NotificationChannelType.NOTIFICATION_CHANNELS,),),),type=OnCallNotificationRuleType.NOTIFICATION_RULES,),)configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=OnCallApi(api_client)response=api_instance.update_user_notification_rule(user_id=USER_DATA_ID,rule_id=ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID,include="channel",body=body)print(response)
# Update an On-Call notification rule for a user returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::OnCallAPI.new# there is a valid "user" in the systemUSER_DATA_ID=ENV["USER_DATA_ID"]# there is a valid "oncall_email_notification_rule" in the systemONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID=ENV["ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID"]# there is a valid "oncall_email_notification_channel" in the systemONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID=ENV["ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID"]body=DatadogAPIClient::V2::UpdateOnCallNotificationRuleRequest.new({data:DatadogAPIClient::V2::UpdateOnCallNotificationRuleRequestData.new({attributes:DatadogAPIClient::V2::UpdateOnCallNotificationRuleRequestAttributes.new({category:DatadogAPIClient::V2::OnCallNotificationRuleCategory::HIGH_URGENCY,delay_minutes:1,}),id:ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID,relationships:DatadogAPIClient::V2::OnCallNotificationRuleRelationships.new({channel:DatadogAPIClient::V2::OnCallNotificationRuleChannelRelationship.new({data:DatadogAPIClient::V2::OnCallNotificationRuleChannelRelationshipData.new({id:ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID,type:DatadogAPIClient::V2::NotificationChannelType::NOTIFICATION_CHANNELS,}),}),}),type:DatadogAPIClient::V2::OnCallNotificationRuleType::NOTIFICATION_RULES,}),})opts={include:"channel",}papi_instance.update_user_notification_rule(USER_DATA_ID,ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID,body,opts)
// Update an On-Call notification rule for a user returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_on_call::OnCallAPI;usedatadog_api_client::datadogV2::api_on_call::UpdateUserNotificationRuleOptionalParams;usedatadog_api_client::datadogV2::model::NotificationChannelType;usedatadog_api_client::datadogV2::model::OnCallNotificationRuleCategory;usedatadog_api_client::datadogV2::model::OnCallNotificationRuleChannelRelationship;usedatadog_api_client::datadogV2::model::OnCallNotificationRuleChannelRelationshipData;usedatadog_api_client::datadogV2::model::OnCallNotificationRuleRelationships;usedatadog_api_client::datadogV2::model::OnCallNotificationRuleType;usedatadog_api_client::datadogV2::model::UpdateOnCallNotificationRuleRequest;usedatadog_api_client::datadogV2::model::UpdateOnCallNotificationRuleRequestAttributes;usedatadog_api_client::datadogV2::model::UpdateOnCallNotificationRuleRequestData;#[tokio::main]asyncfnmain(){// there is a valid "user" in the system
letuser_data_id=std::env::var("USER_DATA_ID").unwrap();// there is a valid "oncall_email_notification_rule" in the system
letoncall_email_notification_rule_data_id=std::env::var("ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID").unwrap();// there is a valid "oncall_email_notification_channel" in the system
letoncall_email_notification_channel_data_id=std::env::var("ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID").unwrap();letbody=UpdateOnCallNotificationRuleRequest::new(UpdateOnCallNotificationRuleRequestData::new(OnCallNotificationRuleType::NOTIFICATION_RULES,).attributes(UpdateOnCallNotificationRuleRequestAttributes::new().category(OnCallNotificationRuleCategory::HIGH_URGENCY).delay_minutes(1),).id(oncall_email_notification_rule_data_id.clone()).relationships(OnCallNotificationRuleRelationships::new().channel(OnCallNotificationRuleChannelRelationship::new(OnCallNotificationRuleChannelRelationshipData::new().id(oncall_email_notification_channel_data_id.clone()).type_(NotificationChannelType::NOTIFICATION_CHANNELS),),),),);letconfiguration=datadog::Configuration::new();letapi=OnCallAPI::with_config(configuration);letresp=api.update_user_notification_rule(user_data_id.clone(),oncall_email_notification_rule_data_id.clone(),body,UpdateUserNotificationRuleOptionalParams::default().include("channel".to_string()),).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Update an On-Call notification rule for a user returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.OnCallApi(configuration);// there is a valid "user" in the system
constUSER_DATA_ID=process.env.USER_DATA_IDasstring;// there is a valid "oncall_email_notification_rule" in the system
constONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID=process.env.ONCALL_EMAIL_NOTIFICATION_RULE_DATA_IDasstring;// there is a valid "oncall_email_notification_channel" in the system
constONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID=process.env.ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_IDasstring;constparams: v2.OnCallApiUpdateUserNotificationRuleRequest={body:{data:{attributes:{category:"high_urgency",delayMinutes: 1,},id: ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID,relationships:{channel:{data:{id: ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID,type:"notification_channels",},},},type:"notification_rules",},},userId: USER_DATA_ID,ruleId: ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID,include:"channel",};apiInstance.updateUserNotificationRule(params).then((data: v2.OnCallNotificationRule)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));