-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Regenerate client from commit a6640b21 of spec repo
- Loading branch information
ci.datadog-api-spec
committed
Oct 31, 2024
1 parent
bed96c8
commit b57ec42
Showing
25 changed files
with
2,383 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Post a change event returns "OK" response | ||
use datadog_api_client::datadog; | ||
use datadog_api_client::datadogV2::api_events::EventsAPI; | ||
use datadog_api_client::datadogV2::model::ChangeEvent; | ||
use datadog_api_client::datadogV2::model::ChangeEventCategory; | ||
use datadog_api_client::datadogV2::model::ChangeEventCreateRequest; | ||
use datadog_api_client::datadogV2::model::ChangeEventCreateRequestPayload; | ||
use datadog_api_client::datadogV2::model::ChangeEventCreateRequestType; | ||
use datadog_api_client::datadogV2::model::ChangeEventCustomAttributes; | ||
use datadog_api_client::datadogV2::model::ChangeEventCustomAttributesAuthor; | ||
use datadog_api_client::datadogV2::model::ChangeEventCustomAttributesAuthorType; | ||
use datadog_api_client::datadogV2::model::ChangeEventCustomAttributesChangedResource; | ||
use datadog_api_client::datadogV2::model::ChangeEventCustomAttributesChangedResourceType; | ||
use datadog_api_client::datadogV2::model::ChangeEventCustomAttributesImpactedResourcesItems; | ||
use datadog_api_client::datadogV2::model::ChangeEventCustomAttributesImpactedResourcesItemsType; | ||
use serde_json::Value; | ||
use std::collections::BTreeMap; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let body = ChangeEventCreateRequestPayload::new().data( | ||
ChangeEventCreateRequest::new() | ||
.attributes( | ||
ChangeEvent::new( | ||
ChangeEventCustomAttributes::new( | ||
ChangeEventCustomAttributesChangedResource::new( | ||
"fallback_payments_test".to_string(), | ||
ChangeEventCustomAttributesChangedResourceType::FEATURE_FLAG, | ||
), | ||
) | ||
.author(ChangeEventCustomAttributesAuthor::new( | ||
"datadog@datadog.com".to_string(), | ||
ChangeEventCustomAttributesAuthorType::USER, | ||
)) | ||
.change_metadata(BTreeMap::from([( | ||
"resource_link".to_string(), | ||
Value::from("datadog.com/feature/fallback_payments_test"), | ||
)])) | ||
.impacted_resources(vec![ | ||
ChangeEventCustomAttributesImpactedResourcesItems::new( | ||
"payments_api".to_string(), | ||
ChangeEventCustomAttributesImpactedResourcesItemsType::SERVICE, | ||
), | ||
]) | ||
.new_value(BTreeMap::from([ | ||
("enabled".to_string(), Value::from(True)), | ||
("percentage".to_string(), Value::from("50%")), | ||
])) | ||
.prev_value(BTreeMap::from([ | ||
("enabled".to_string(), Value::from(True)), | ||
("percentage".to_string(), Value::from("10%")), | ||
])), | ||
ChangeEventCategory::CHANGE, | ||
"payment_processed feature flag updated".to_string(), | ||
) | ||
.message("payment_processed feature flag has been enabled".to_string()) | ||
.tags(vec!["environment:test".to_string()]), | ||
) | ||
.type_(ChangeEventCreateRequestType::EVENT), | ||
); | ||
let configuration = datadog::Configuration::new(); | ||
let api = EventsAPI::with_config(configuration); | ||
let resp = api.create_event(body).await; | ||
if let Ok(value) = resp { | ||
println!("{:#?}", value); | ||
} else { | ||
println!("{:#?}", resp.unwrap_err()); | ||
} | ||
} |
Oops, something went wrong.