// Create deployment rule 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 "deployment_gate" in the systemDeploymentGateDataID:=os.Getenv("DEPLOYMENT_GATE_DATA_ID")body:=datadogV2.CreateDeploymentRuleParams{Data:&datadogV2.CreateDeploymentRuleParamsData{Attributes:datadogV2.CreateDeploymentRuleParamsDataAttributes{DryRun:datadog.PtrBool(false),Name:"My deployment rule",Options:datadogV2.DeploymentRulesOptions{DeploymentRuleOptionsFaultyDeploymentDetection:&datadogV2.DeploymentRuleOptionsFaultyDeploymentDetection{ExcludedResources:[]string{},}},Type:"faulty_deployment_detection",},Type:datadogV2.DEPLOYMENTRULEDATATYPE_DEPLOYMENT_RULE,},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()configuration.SetUnstableOperationEnabled("v2.CreateDeploymentRule",true)apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewDeploymentGatesApi(apiClient)resp,r,err:=api.CreateDeploymentRule(ctx,DeploymentGateDataID,body)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `DeploymentGatesApi.CreateDeploymentRule`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `DeploymentGatesApi.CreateDeploymentRule`:\n%s\n",responseContent)}
// Create deployment rule returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.DeploymentGatesApi;importcom.datadog.api.client.v2.model.CreateDeploymentRuleParams;importcom.datadog.api.client.v2.model.CreateDeploymentRuleParamsData;importcom.datadog.api.client.v2.model.CreateDeploymentRuleParamsDataAttributes;importcom.datadog.api.client.v2.model.DeploymentRuleDataType;importcom.datadog.api.client.v2.model.DeploymentRuleOptionsFaultyDeploymentDetection;importcom.datadog.api.client.v2.model.DeploymentRuleResponse;importcom.datadog.api.client.v2.model.DeploymentRulesOptions;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();defaultClient.setUnstableOperationEnabled("v2.createDeploymentRule",true);DeploymentGatesApiapiInstance=newDeploymentGatesApi(defaultClient);// there is a valid "deployment_gate" in the systemStringDEPLOYMENT_GATE_DATA_ID=System.getenv("DEPLOYMENT_GATE_DATA_ID");CreateDeploymentRuleParamsbody=newCreateDeploymentRuleParams().data(newCreateDeploymentRuleParamsData().attributes(newCreateDeploymentRuleParamsDataAttributes().dryRun(false).name("My deployment rule").options(newDeploymentRulesOptions(newDeploymentRuleOptionsFaultyDeploymentDetection())).type("faulty_deployment_detection")).type(DeploymentRuleDataType.DEPLOYMENT_RULE));try{DeploymentRuleResponseresult=apiInstance.createDeploymentRule(DEPLOYMENT_GATE_DATA_ID,body);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling DeploymentGatesApi#createDeploymentRule");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
"""
Create deployment rule returns "OK" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.deployment_gates_apiimportDeploymentGatesApifromdatadog_api_client.v2.model.create_deployment_rule_paramsimportCreateDeploymentRuleParamsfromdatadog_api_client.v2.model.create_deployment_rule_params_dataimportCreateDeploymentRuleParamsDatafromdatadog_api_client.v2.model.create_deployment_rule_params_data_attributesimport(CreateDeploymentRuleParamsDataAttributes,)fromdatadog_api_client.v2.model.deployment_rule_data_typeimportDeploymentRuleDataTypefromdatadog_api_client.v2.model.deployment_rule_options_faulty_deployment_detectionimport(DeploymentRuleOptionsFaultyDeploymentDetection,)# there is a valid "deployment_gate" in the systemDEPLOYMENT_GATE_DATA_ID=environ["DEPLOYMENT_GATE_DATA_ID"]body=CreateDeploymentRuleParams(data=CreateDeploymentRuleParamsData(attributes=CreateDeploymentRuleParamsDataAttributes(dry_run=False,name="My deployment rule",options=DeploymentRuleOptionsFaultyDeploymentDetection(excluded_resources=[],),type="faulty_deployment_detection",),type=DeploymentRuleDataType.DEPLOYMENT_RULE,),)configuration=Configuration()configuration.unstable_operations["create_deployment_rule"]=TruewithApiClient(configuration)asapi_client:api_instance=DeploymentGatesApi(api_client)response=api_instance.create_deployment_rule(gate_id=DEPLOYMENT_GATE_DATA_ID,body=body)print(response)
# Create deployment rule returns "OK" responserequire"datadog_api_client"DatadogAPIClient.configuredo|config|config.unstable_operations["v2.create_deployment_rule".to_sym]=trueendapi_instance=DatadogAPIClient::V2::DeploymentGatesAPI.new# there is a valid "deployment_gate" in the systemDEPLOYMENT_GATE_DATA_ID=ENV["DEPLOYMENT_GATE_DATA_ID"]body=DatadogAPIClient::V2::CreateDeploymentRuleParams.new({data:DatadogAPIClient::V2::CreateDeploymentRuleParamsData.new({attributes:DatadogAPIClient::V2::CreateDeploymentRuleParamsDataAttributes.new({dry_run:false,name:"My deployment rule",options:DatadogAPIClient::V2::DeploymentRuleOptionsFaultyDeploymentDetection.new({excluded_resources:[],}),type:"faulty_deployment_detection",}),type:DatadogAPIClient::V2::DeploymentRuleDataType::DEPLOYMENT_RULE,}),})papi_instance.create_deployment_rule(DEPLOYMENT_GATE_DATA_ID,body)
// Create deployment rule returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_deployment_gates::DeploymentGatesAPI;usedatadog_api_client::datadogV2::model::CreateDeploymentRuleParams;usedatadog_api_client::datadogV2::model::CreateDeploymentRuleParamsData;usedatadog_api_client::datadogV2::model::CreateDeploymentRuleParamsDataAttributes;usedatadog_api_client::datadogV2::model::DeploymentRuleDataType;usedatadog_api_client::datadogV2::model::DeploymentRuleOptionsFaultyDeploymentDetection;usedatadog_api_client::datadogV2::model::DeploymentRulesOptions;#[tokio::main]asyncfnmain(){// there is a valid "deployment_gate" in the system
letdeployment_gate_data_id=std::env::var("DEPLOYMENT_GATE_DATA_ID").unwrap();letbody=CreateDeploymentRuleParams::new().data(CreateDeploymentRuleParamsData::new(CreateDeploymentRuleParamsDataAttributes::new("My deployment rule".to_string(),DeploymentRulesOptions::DeploymentRuleOptionsFaultyDeploymentDetection(Box::new(DeploymentRuleOptionsFaultyDeploymentDetection::new().excluded_resources(vec![]),)),"faulty_deployment_detection".to_string(),).dry_run(false),DeploymentRuleDataType::DEPLOYMENT_RULE,));letmutconfiguration=datadog::Configuration::new();configuration.set_unstable_operation_enabled("v2.CreateDeploymentRule",true);letapi=DeploymentGatesAPI::with_config(configuration);letresp=api.create_deployment_rule(deployment_gate_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.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Create deployment rule returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();configuration.unstableOperations["v2.createDeploymentRule"]=true;constapiInstance=newv2.DeploymentGatesApi(configuration);// there is a valid "deployment_gate" in the system
constDEPLOYMENT_GATE_DATA_ID=process.env.DEPLOYMENT_GATE_DATA_IDasstring;constparams: v2.DeploymentGatesApiCreateDeploymentRuleRequest={body:{data:{attributes:{dryRun: false,name:"My deployment rule",options:{excludedResources:[],},type:"faulty_deployment_detection",},type:"deployment_rule",},},gateId: DEPLOYMENT_GATE_DATA_ID,};apiInstance.createDeploymentRule(params).then((data: v2.DeploymentRuleResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));