diff --git a/.apigentools-info b/.apigentools-info index 8a616fdaf..ca745f74c 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-10-09 15:02:58.368064", - "spec_repo_commit": "43ae024c" + "regenerated": "2024-10-09 19:21:12.799981", + "spec_repo_commit": "5366e690" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-10-09 15:02:58.386563", - "spec_repo_commit": "43ae024c" + "regenerated": "2024-10-09 19:21:12.818481", + "spec_repo_commit": "5366e690" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 3ee9a258d..3f7b5cd12 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -3951,6 +3951,223 @@ components: format: int64 type: integer type: object + ChangeEvent: + description: Object representing a change event. + properties: + aggregation_key: + description: 'An arbitrary string to use for aggregation. Limited to 100 + characters. + + If you specify a key, all events using that key are grouped together in + the Event Stream.' + maxLength: 100 + type: string + attributes: + $ref: '#/components/schemas/ChangeEventCustomAttributes' + category: + $ref: '#/components/schemas/ChangeEventCategory' + message: + description: The body of the event. Limited to 4000 characters. + example: payment_processed feature flag has been enabled + maxLength: 4000 + type: string + tags: + description: 'A list of tags to apply to the event. + + Refer to [Tags docs](https://docs.datadoghq.com/getting_started/tagging/).' + example: + - environment:test + items: + description: A tag. + type: string + type: array + timestamp: + description: 'Timestamp in which the event occurred. Must follow [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) + format. + + For example `"2017-01-15T01:30:15.010000Z"`. + + Defaults to now. Limited to values no older than 18 hours.' + type: string + title: + description: The event title. Limited to 500 characters. + example: payment_processed feature flag updated + maxLength: 500 + type: string + required: + - title + - category + - attributes + type: object + ChangeEventCategory: + description: Event category to identify the type of event. Only the value `change` + is supported. + enum: + - change + example: change + type: string + x-enum-varnames: + - CHANGE + ChangeEventCreateRequest: + description: Object representing an event. + properties: + attributes: + $ref: '#/components/schemas/ChangeEvent' + type: + $ref: '#/components/schemas/ChangeEventCreateRequestType' + type: object + ChangeEventCreateRequestType: + description: Entity type. + enum: + - event + type: string + x-enum-varnames: + - EVENT + ChangeEventCreateResponse: + description: Object containing an event response. + properties: + attributes: + $ref: '#/components/schemas/ChangeEventCreateResponseAttributes' + type: + description: Event type + type: string + type: object + ChangeEventCreateResponseAttributes: + description: The definition of `ChangeEventCreateResponseAttributes` object. + properties: + attributes: + $ref: '#/components/schemas/ChangeEventCreateResponseAttributesAttributes' + type: object + ChangeEventCreateResponseAttributesAttributes: + description: The definition of `ChangeEventCreateResponseAttributesAttributes` + object. + properties: + evt: + $ref: '#/components/schemas/ChangeEventCreateResponseAttributesAttributesEvt' + type: object + ChangeEventCreateResponseAttributesAttributesEvt: + description: The definition of `ChangeEventCreateResponseAttributesAttributesEvt` + object. + properties: + id: + description: Event id + type: string + type: object + ChangeEventCustomAttributes: + description: Object representing custom event attributes. + properties: + author: + $ref: '#/components/schemas/ChangeEventCustomAttributesAuthor' + change_metadata: + description: Free form object with any related information of the `change` + event. + example: + resource_link: /feature/fallback_payments_test + user: + email: dd_user_email + name: dd_user + type: object + changed_resource: + $ref: '#/components/schemas/ChangeEventCustomAttributesChangedResource' + impacted_resources: + description: 'A list of resources impacted by this change. At least one + resource is required. Only resources + + of type `service` are supported.' + example: + - name: payments_api + type: service + items: + $ref: '#/components/schemas/ChangeEventCustomAttributesImpactedResourcesItems' + type: array + new_value: + description: Free form object to track new value of the changed resource. + example: + enabled: true + percentage: 50% + rule: + datacenter: us1.prod + type: object + prev_value: + description: Free form object to track previous value of the changed resource. + example: + enabled: true + percentage: 10% + rule: + datacenter: us1.prod + type: object + required: + - changed_resource + type: object + ChangeEventCustomAttributesAuthor: + description: Object representing the entity which made the change. Optional + field but if provided should include `type` and `name`. + properties: + name: + description: Author's name. Limited to 128 characters. + example: '' + maxLength: 128.0 + type: string + type: + $ref: '#/components/schemas/ChangeEventCustomAttributesAuthorType' + required: + - name + - type + type: object + ChangeEventCustomAttributesAuthorType: + description: Author's type. + enum: + - user + - system + example: user + type: string + x-enum-varnames: + - USER + - SYSTEM + ChangeEventCustomAttributesChangedResource: + description: Object representing a uniquely identified resource. Only the resource + type `feature_flag` is supported. + properties: + name: + description: Resource's name. + example: fallback_payments_test + type: string + type: + $ref: '#/components/schemas/ChangeEventCustomAttributesChangedResourceType' + required: + - type + - name + type: object + ChangeEventCustomAttributesChangedResourceType: + description: Resource's type. + enum: + - feature_flag + example: feature_flag + type: string + x-enum-varnames: + - FEATURE_FLAG + ChangeEventCustomAttributesImpactedResourcesItems: + description: Object representing a uniquely identified resource. Only the resource + type `service` is supported. + properties: + name: + description: Resource's name. + example: payments_api + type: string + type: + $ref: '#/components/schemas/ChangeEventCustomAttributesImpactedResourcesItemsType' + required: + - type + - name + type: object + ChangeEventCustomAttributesImpactedResourcesItemsType: + description: Resource's type. + enum: + - service + example: service + type: string + x-enum-varnames: + - SERVICE ChargebackBreakdown: description: Charges breakdown. properties: @@ -29664,6 +29881,32 @@ paths: operator: OR permissions: - events_read + post: + description: This endpoint allows you to post events. Only events with `change` + category are supported. + operationId: CreateEvent + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChangeEventCreateRequest' + description: Event request object + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ChangeEventCreateResponse' + description: OK + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + summary: Post a change event + tags: + - Events + x-codegen-request-body-name: body /api/v2/events/search: post: description: 'List endpoint returns events that match an events search query. diff --git a/examples/v2_events_CreateEvent.rs b/examples/v2_events_CreateEvent.rs new file mode 100644 index 000000000..ec3e5b7f5 --- /dev/null +++ b/examples/v2_events_CreateEvent.rs @@ -0,0 +1,54 @@ +// 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::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 std::collections::BTreeMap; + +#[tokio::main] +async fn main() { + let body = ChangeEventCreateRequest::new() + .attributes( + ChangeEvent::new( + ChangeEventCustomAttributes::new(ChangeEventCustomAttributesChangedResource::new( + "fallback_payments_test".to_string(), + ChangeEventCustomAttributesChangedResourceType::FEATURE_FLAG, + )) + .author(ChangeEventCustomAttributesAuthor::new( + "".to_string(), + ChangeEventCustomAttributesAuthorType::USER, + )) + .change_metadata(BTreeMap::new()) + .impacted_resources(vec![ + ChangeEventCustomAttributesImpactedResourcesItems::new( + "payments_api".to_string(), + ChangeEventCustomAttributesImpactedResourcesItemsType::SERVICE, + ), + ]) + .new_value(BTreeMap::new()) + .prev_value(BTreeMap::new()), + 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()); + } +} diff --git a/src/datadogV2/api/api_events.rs b/src/datadogV2/api/api_events.rs index be74840d0..5c937e8fe 100644 --- a/src/datadogV2/api/api_events.rs +++ b/src/datadogV2/api/api_events.rs @@ -77,6 +77,14 @@ impl SearchEventsOptionalParams { } } +/// CreateEventError is a struct for typed errors of method [`EventsAPI::create_event`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateEventError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// ListEventsError is a struct for typed errors of method [`EventsAPI::list_events`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -159,6 +167,150 @@ impl EventsAPI { Self { config, client } } + /// This endpoint allows you to post events. Only events with `change` category are supported. + pub async fn create_event( + &self, + body: crate::datadogV2::model::ChangeEventCreateRequest, + ) -> Result> + { + match self.create_event_with_http_info(body).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// This endpoint allows you to post events. Only events with `change` category are supported. + pub async fn create_event_with_http_info( + &self, + body: crate::datadogV2::model::ChangeEventCreateRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_event"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/events", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + /// List endpoint returns events that match an events search query. /// [Results are paginated similarly to logs](). /// diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index daa37d736..29f4ab6e8 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -1034,6 +1034,36 @@ pub mod model_events_response_metadata_page; pub use self::model_events_response_metadata_page::EventsResponseMetadataPage; pub mod model_events_warning; pub use self::model_events_warning::EventsWarning; +pub mod model_change_event_create_request; +pub use self::model_change_event_create_request::ChangeEventCreateRequest; +pub mod model_change_event; +pub use self::model_change_event::ChangeEvent; +pub mod model_change_event_custom_attributes; +pub use self::model_change_event_custom_attributes::ChangeEventCustomAttributes; +pub mod model_change_event_custom_attributes_author; +pub use self::model_change_event_custom_attributes_author::ChangeEventCustomAttributesAuthor; +pub mod model_change_event_custom_attributes_author_type; +pub use self::model_change_event_custom_attributes_author_type::ChangeEventCustomAttributesAuthorType; +pub mod model_change_event_custom_attributes_changed_resource; +pub use self::model_change_event_custom_attributes_changed_resource::ChangeEventCustomAttributesChangedResource; +pub mod model_change_event_custom_attributes_changed_resource_type; +pub use self::model_change_event_custom_attributes_changed_resource_type::ChangeEventCustomAttributesChangedResourceType; +pub mod model_change_event_custom_attributes_impacted_resources_items; +pub use self::model_change_event_custom_attributes_impacted_resources_items::ChangeEventCustomAttributesImpactedResourcesItems; +pub mod model_change_event_custom_attributes_impacted_resources_items_type; +pub use self::model_change_event_custom_attributes_impacted_resources_items_type::ChangeEventCustomAttributesImpactedResourcesItemsType; +pub mod model_change_event_category; +pub use self::model_change_event_category::ChangeEventCategory; +pub mod model_change_event_create_request_type; +pub use self::model_change_event_create_request_type::ChangeEventCreateRequestType; +pub mod model_change_event_create_response; +pub use self::model_change_event_create_response::ChangeEventCreateResponse; +pub mod model_change_event_create_response_attributes; +pub use self::model_change_event_create_response_attributes::ChangeEventCreateResponseAttributes; +pub mod model_change_event_create_response_attributes_attributes; +pub use self::model_change_event_create_response_attributes_attributes::ChangeEventCreateResponseAttributesAttributes; +pub mod model_change_event_create_response_attributes_attributes_evt; +pub use self::model_change_event_create_response_attributes_attributes_evt::ChangeEventCreateResponseAttributesAttributesEvt; pub mod model_events_list_request; pub use self::model_events_list_request::EventsListRequest; pub mod model_events_query_filter; diff --git a/src/datadogV2/model/model_change_event.rs b/src/datadogV2/model/model_change_event.rs new file mode 100644 index 000000000..cf9ee61c5 --- /dev/null +++ b/src/datadogV2/model/model_change_event.rs @@ -0,0 +1,198 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Object representing a change event. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ChangeEvent { + /// An arbitrary string to use for aggregation. Limited to 100 characters. + /// If you specify a key, all events using that key are grouped together in the Event Stream. + #[serde(rename = "aggregation_key")] + pub aggregation_key: Option, + /// Object representing custom event attributes. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::ChangeEventCustomAttributes, + /// Event category to identify the type of event. Only the value `change` is supported. + #[serde(rename = "category")] + pub category: crate::datadogV2::model::ChangeEventCategory, + /// The body of the event. Limited to 4000 characters. + #[serde(rename = "message")] + pub message: Option, + /// A list of tags to apply to the event. + /// Refer to [Tags docs](). + #[serde(rename = "tags")] + pub tags: Option>, + /// Timestamp in which the event occurred. Must follow [ISO 8601]() format. + /// For example `"2017-01-15T01:30:15.010000Z"`. + /// Defaults to now. Limited to values no older than 18 hours. + #[serde(rename = "timestamp")] + pub timestamp: Option, + /// The event title. Limited to 500 characters. + #[serde(rename = "title")] + pub title: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ChangeEvent { + pub fn new( + attributes: crate::datadogV2::model::ChangeEventCustomAttributes, + category: crate::datadogV2::model::ChangeEventCategory, + title: String, + ) -> ChangeEvent { + ChangeEvent { + aggregation_key: None, + attributes, + category, + message: None, + tags: None, + timestamp: None, + title, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn aggregation_key(mut self, value: String) -> Self { + self.aggregation_key = Some(value); + self + } + + pub fn message(mut self, value: String) -> Self { + self.message = Some(value); + self + } + + pub fn tags(mut self, value: Vec) -> Self { + self.tags = Some(value); + self + } + + pub fn timestamp(mut self, value: String) -> Self { + self.timestamp = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ChangeEvent { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ChangeEventVisitor; + impl<'a> Visitor<'a> for ChangeEventVisitor { + type Value = ChangeEvent; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut aggregation_key: Option = None; + let mut attributes: Option = + None; + let mut category: Option = None; + let mut message: Option = None; + let mut tags: Option> = None; + let mut timestamp: Option = None; + let mut title: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "aggregation_key" => { + if v.is_null() { + continue; + } + aggregation_key = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "category" => { + category = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _category) = category { + match _category { + crate::datadogV2::model::ChangeEventCategory::UnparsedObject(_category) => { + _unparsed = true; + }, + _ => {} + } + } + } + "message" => { + if v.is_null() { + continue; + } + message = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "tags" => { + if v.is_null() { + continue; + } + tags = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "timestamp" => { + if v.is_null() { + continue; + } + timestamp = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "title" => { + title = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let category = category.ok_or_else(|| M::Error::missing_field("category"))?; + let title = title.ok_or_else(|| M::Error::missing_field("title"))?; + + let content = ChangeEvent { + aggregation_key, + attributes, + category, + message, + tags, + timestamp, + title, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ChangeEventVisitor) + } +} diff --git a/src/datadogV2/model/model_change_event_category.rs b/src/datadogV2/model/model_change_event_category.rs new file mode 100644 index 000000000..014c0b87b --- /dev/null +++ b/src/datadogV2/model/model_change_event_category.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum ChangeEventCategory { + CHANGE, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ChangeEventCategory { + fn to_string(&self) -> String { + match self { + Self::CHANGE => String::from("change"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ChangeEventCategory { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for ChangeEventCategory { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "change" => Self::CHANGE, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_change_event_create_request.rs b/src/datadogV2/model/model_change_event_create_request.rs new file mode 100644 index 000000000..bc43d47bc --- /dev/null +++ b/src/datadogV2/model/model_change_event_create_request.rs @@ -0,0 +1,130 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Object representing an event. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ChangeEventCreateRequest { + /// Object representing a change event. + #[serde(rename = "attributes")] + pub attributes: Option, + /// Entity type. + #[serde(rename = "type")] + pub type_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ChangeEventCreateRequest { + pub fn new() -> ChangeEventCreateRequest { + ChangeEventCreateRequest { + attributes: None, + type_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes(mut self, value: crate::datadogV2::model::ChangeEvent) -> Self { + self.attributes = Some(value); + self + } + + pub fn type_(mut self, value: crate::datadogV2::model::ChangeEventCreateRequestType) -> Self { + self.type_ = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ChangeEventCreateRequest { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ChangeEventCreateRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ChangeEventCreateRequestVisitor; + impl<'a> Visitor<'a> for ChangeEventCreateRequestVisitor { + type Value = ChangeEventCreateRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + if v.is_null() { + continue; + } + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::ChangeEventCreateRequestType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ChangeEventCreateRequest { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ChangeEventCreateRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_change_event_create_request_type.rs b/src/datadogV2/model/model_change_event_create_request_type.rs new file mode 100644 index 000000000..78cfcbe7c --- /dev/null +++ b/src/datadogV2/model/model_change_event_create_request_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum ChangeEventCreateRequestType { + EVENT, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ChangeEventCreateRequestType { + fn to_string(&self) -> String { + match self { + Self::EVENT => String::from("event"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ChangeEventCreateRequestType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for ChangeEventCreateRequestType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "event" => Self::EVENT, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_change_event_create_response.rs b/src/datadogV2/model/model_change_event_create_response.rs new file mode 100644 index 000000000..fca427938 --- /dev/null +++ b/src/datadogV2/model/model_change_event_create_response.rs @@ -0,0 +1,127 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Object containing an event response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ChangeEventCreateResponse { + /// The definition of `ChangeEventCreateResponseAttributes` object. + #[serde(rename = "attributes")] + pub attributes: Option, + /// Event type + #[serde(rename = "type")] + pub type_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ChangeEventCreateResponse { + pub fn new() -> ChangeEventCreateResponse { + ChangeEventCreateResponse { + attributes: None, + type_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::ChangeEventCreateResponseAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn type_(mut self, value: String) -> Self { + self.type_ = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ChangeEventCreateResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ChangeEventCreateResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ChangeEventCreateResponseVisitor; + impl<'a> Visitor<'a> for ChangeEventCreateResponseVisitor { + type Value = ChangeEventCreateResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::ChangeEventCreateResponseAttributes, + > = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + if v.is_null() { + continue; + } + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ChangeEventCreateResponse { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ChangeEventCreateResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_change_event_create_response_attributes.rs b/src/datadogV2/model/model_change_event_create_response_attributes.rs new file mode 100644 index 000000000..c7435d856 --- /dev/null +++ b/src/datadogV2/model/model_change_event_create_response_attributes.rs @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `ChangeEventCreateResponseAttributes` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ChangeEventCreateResponseAttributes { + /// The definition of `ChangeEventCreateResponseAttributesAttributes` object. + #[serde(rename = "attributes")] + pub attributes: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ChangeEventCreateResponseAttributes { + pub fn new() -> ChangeEventCreateResponseAttributes { + ChangeEventCreateResponseAttributes { + attributes: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::ChangeEventCreateResponseAttributesAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ChangeEventCreateResponseAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ChangeEventCreateResponseAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ChangeEventCreateResponseAttributesVisitor; + impl<'a> Visitor<'a> for ChangeEventCreateResponseAttributesVisitor { + type Value = ChangeEventCreateResponseAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::ChangeEventCreateResponseAttributesAttributes, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ChangeEventCreateResponseAttributes { + attributes, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ChangeEventCreateResponseAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_change_event_create_response_attributes_attributes.rs b/src/datadogV2/model/model_change_event_create_response_attributes_attributes.rs new file mode 100644 index 000000000..2659fde3f --- /dev/null +++ b/src/datadogV2/model/model_change_event_create_response_attributes_attributes.rs @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `ChangeEventCreateResponseAttributesAttributes` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ChangeEventCreateResponseAttributesAttributes { + /// The definition of `ChangeEventCreateResponseAttributesAttributesEvt` object. + #[serde(rename = "evt")] + pub evt: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ChangeEventCreateResponseAttributesAttributes { + pub fn new() -> ChangeEventCreateResponseAttributesAttributes { + ChangeEventCreateResponseAttributesAttributes { + evt: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn evt( + mut self, + value: crate::datadogV2::model::ChangeEventCreateResponseAttributesAttributesEvt, + ) -> Self { + self.evt = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ChangeEventCreateResponseAttributesAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ChangeEventCreateResponseAttributesAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ChangeEventCreateResponseAttributesAttributesVisitor; + impl<'a> Visitor<'a> for ChangeEventCreateResponseAttributesAttributesVisitor { + type Value = ChangeEventCreateResponseAttributesAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut evt: Option< + crate::datadogV2::model::ChangeEventCreateResponseAttributesAttributesEvt, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "evt" => { + if v.is_null() { + continue; + } + evt = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ChangeEventCreateResponseAttributesAttributes { + evt, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ChangeEventCreateResponseAttributesAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_change_event_create_response_attributes_attributes_evt.rs b/src/datadogV2/model/model_change_event_create_response_attributes_attributes_evt.rs new file mode 100644 index 000000000..444966e87 --- /dev/null +++ b/src/datadogV2/model/model_change_event_create_response_attributes_attributes_evt.rs @@ -0,0 +1,105 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `ChangeEventCreateResponseAttributesAttributesEvt` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ChangeEventCreateResponseAttributesAttributesEvt { + /// Event id + #[serde(rename = "id")] + pub id: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ChangeEventCreateResponseAttributesAttributesEvt { + pub fn new() -> ChangeEventCreateResponseAttributesAttributesEvt { + ChangeEventCreateResponseAttributesAttributesEvt { + id: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ChangeEventCreateResponseAttributesAttributesEvt { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ChangeEventCreateResponseAttributesAttributesEvt { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ChangeEventCreateResponseAttributesAttributesEvtVisitor; + impl<'a> Visitor<'a> for ChangeEventCreateResponseAttributesAttributesEvtVisitor { + type Value = ChangeEventCreateResponseAttributesAttributesEvt; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ChangeEventCreateResponseAttributesAttributesEvt { + id, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ChangeEventCreateResponseAttributesAttributesEvtVisitor) + } +} diff --git a/src/datadogV2/model/model_change_event_custom_attributes.rs b/src/datadogV2/model/model_change_event_custom_attributes.rs new file mode 100644 index 000000000..b75f960f0 --- /dev/null +++ b/src/datadogV2/model/model_change_event_custom_attributes.rs @@ -0,0 +1,209 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Object representing custom event attributes. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ChangeEventCustomAttributes { + /// Object representing the entity which made the change. Optional field but if provided should include `type` and `name`. + #[serde(rename = "author")] + pub author: Option, + /// Free form object with any related information of the `change` event. + #[serde(rename = "change_metadata")] + pub change_metadata: Option>, + /// Object representing a uniquely identified resource. Only the resource type `feature_flag` is supported. + #[serde(rename = "changed_resource")] + pub changed_resource: crate::datadogV2::model::ChangeEventCustomAttributesChangedResource, + /// A list of resources impacted by this change. At least one resource is required. Only resources + /// of type `service` are supported. + #[serde(rename = "impacted_resources")] + pub impacted_resources: + Option>, + /// Free form object to track new value of the changed resource. + #[serde(rename = "new_value")] + pub new_value: Option>, + /// Free form object to track previous value of the changed resource. + #[serde(rename = "prev_value")] + pub prev_value: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ChangeEventCustomAttributes { + pub fn new( + changed_resource: crate::datadogV2::model::ChangeEventCustomAttributesChangedResource, + ) -> ChangeEventCustomAttributes { + ChangeEventCustomAttributes { + author: None, + change_metadata: None, + changed_resource, + impacted_resources: None, + new_value: None, + prev_value: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn author( + mut self, + value: crate::datadogV2::model::ChangeEventCustomAttributesAuthor, + ) -> Self { + self.author = Some(value); + self + } + + pub fn change_metadata( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.change_metadata = Some(value); + self + } + + pub fn impacted_resources( + mut self, + value: Vec, + ) -> Self { + self.impacted_resources = Some(value); + self + } + + pub fn new_value( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.new_value = Some(value); + self + } + + pub fn prev_value( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.prev_value = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ChangeEventCustomAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ChangeEventCustomAttributesVisitor; + impl<'a> Visitor<'a> for ChangeEventCustomAttributesVisitor { + type Value = ChangeEventCustomAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut author: Option = + None; + let mut change_metadata: Option< + std::collections::BTreeMap, + > = None; + let mut changed_resource: Option< + crate::datadogV2::model::ChangeEventCustomAttributesChangedResource, + > = None; + let mut impacted_resources: Option< + Vec, + > = None; + let mut new_value: Option> = + None; + let mut prev_value: Option> = + None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "author" => { + if v.is_null() { + continue; + } + author = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "change_metadata" => { + if v.is_null() { + continue; + } + change_metadata = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "changed_resource" => { + changed_resource = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "impacted_resources" => { + if v.is_null() { + continue; + } + impacted_resources = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "new_value" => { + if v.is_null() { + continue; + } + new_value = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "prev_value" => { + if v.is_null() { + continue; + } + prev_value = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let changed_resource = + changed_resource.ok_or_else(|| M::Error::missing_field("changed_resource"))?; + + let content = ChangeEventCustomAttributes { + author, + change_metadata, + changed_resource, + impacted_resources, + new_value, + prev_value, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ChangeEventCustomAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_change_event_custom_attributes_author.rs b/src/datadogV2/model/model_change_event_custom_attributes_author.rs new file mode 100644 index 000000000..f18b0ae18 --- /dev/null +++ b/src/datadogV2/model/model_change_event_custom_attributes_author.rs @@ -0,0 +1,115 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Object representing the entity which made the change. Optional field but if provided should include `type` and `name`. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ChangeEventCustomAttributesAuthor { + /// Author's name. Limited to 128 characters. + #[serde(rename = "name")] + pub name: String, + /// Author's type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::ChangeEventCustomAttributesAuthorType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ChangeEventCustomAttributesAuthor { + pub fn new( + name: String, + type_: crate::datadogV2::model::ChangeEventCustomAttributesAuthorType, + ) -> ChangeEventCustomAttributesAuthor { + ChangeEventCustomAttributesAuthor { + name, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ChangeEventCustomAttributesAuthor { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ChangeEventCustomAttributesAuthorVisitor; + impl<'a> Visitor<'a> for ChangeEventCustomAttributesAuthorVisitor { + type Value = ChangeEventCustomAttributesAuthor; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut name: Option = None; + let mut type_: Option< + crate::datadogV2::model::ChangeEventCustomAttributesAuthorType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::ChangeEventCustomAttributesAuthorType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = ChangeEventCustomAttributesAuthor { + name, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ChangeEventCustomAttributesAuthorVisitor) + } +} diff --git a/src/datadogV2/model/model_change_event_custom_attributes_author_type.rs b/src/datadogV2/model/model_change_event_custom_attributes_author_type.rs new file mode 100644 index 000000000..9e657c6ca --- /dev/null +++ b/src/datadogV2/model/model_change_event_custom_attributes_author_type.rs @@ -0,0 +1,51 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum ChangeEventCustomAttributesAuthorType { + USER, + SYSTEM, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ChangeEventCustomAttributesAuthorType { + fn to_string(&self) -> String { + match self { + Self::USER => String::from("user"), + Self::SYSTEM => String::from("system"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ChangeEventCustomAttributesAuthorType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for ChangeEventCustomAttributesAuthorType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "user" => Self::USER, + "system" => Self::SYSTEM, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_change_event_custom_attributes_changed_resource.rs b/src/datadogV2/model/model_change_event_custom_attributes_changed_resource.rs new file mode 100644 index 000000000..e77f890cc --- /dev/null +++ b/src/datadogV2/model/model_change_event_custom_attributes_changed_resource.rs @@ -0,0 +1,115 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Object representing a uniquely identified resource. Only the resource type `feature_flag` is supported. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ChangeEventCustomAttributesChangedResource { + /// Resource's name. + #[serde(rename = "name")] + pub name: String, + /// Resource's type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::ChangeEventCustomAttributesChangedResourceType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ChangeEventCustomAttributesChangedResource { + pub fn new( + name: String, + type_: crate::datadogV2::model::ChangeEventCustomAttributesChangedResourceType, + ) -> ChangeEventCustomAttributesChangedResource { + ChangeEventCustomAttributesChangedResource { + name, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ChangeEventCustomAttributesChangedResource { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ChangeEventCustomAttributesChangedResourceVisitor; + impl<'a> Visitor<'a> for ChangeEventCustomAttributesChangedResourceVisitor { + type Value = ChangeEventCustomAttributesChangedResource; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut name: Option = None; + let mut type_: Option< + crate::datadogV2::model::ChangeEventCustomAttributesChangedResourceType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::ChangeEventCustomAttributesChangedResourceType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = ChangeEventCustomAttributesChangedResource { + name, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ChangeEventCustomAttributesChangedResourceVisitor) + } +} diff --git a/src/datadogV2/model/model_change_event_custom_attributes_changed_resource_type.rs b/src/datadogV2/model/model_change_event_custom_attributes_changed_resource_type.rs new file mode 100644 index 000000000..2a0775426 --- /dev/null +++ b/src/datadogV2/model/model_change_event_custom_attributes_changed_resource_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum ChangeEventCustomAttributesChangedResourceType { + FEATURE_FLAG, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ChangeEventCustomAttributesChangedResourceType { + fn to_string(&self) -> String { + match self { + Self::FEATURE_FLAG => String::from("feature_flag"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ChangeEventCustomAttributesChangedResourceType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for ChangeEventCustomAttributesChangedResourceType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "feature_flag" => Self::FEATURE_FLAG, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_change_event_custom_attributes_impacted_resources_items.rs b/src/datadogV2/model/model_change_event_custom_attributes_impacted_resources_items.rs new file mode 100644 index 000000000..bfa7b99a3 --- /dev/null +++ b/src/datadogV2/model/model_change_event_custom_attributes_impacted_resources_items.rs @@ -0,0 +1,115 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Object representing a uniquely identified resource. Only the resource type `service` is supported. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ChangeEventCustomAttributesImpactedResourcesItems { + /// Resource's name. + #[serde(rename = "name")] + pub name: String, + /// Resource's type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::ChangeEventCustomAttributesImpactedResourcesItemsType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ChangeEventCustomAttributesImpactedResourcesItems { + pub fn new( + name: String, + type_: crate::datadogV2::model::ChangeEventCustomAttributesImpactedResourcesItemsType, + ) -> ChangeEventCustomAttributesImpactedResourcesItems { + ChangeEventCustomAttributesImpactedResourcesItems { + name, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ChangeEventCustomAttributesImpactedResourcesItems { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ChangeEventCustomAttributesImpactedResourcesItemsVisitor; + impl<'a> Visitor<'a> for ChangeEventCustomAttributesImpactedResourcesItemsVisitor { + type Value = ChangeEventCustomAttributesImpactedResourcesItems; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut name: Option = None; + let mut type_: Option< + crate::datadogV2::model::ChangeEventCustomAttributesImpactedResourcesItemsType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::ChangeEventCustomAttributesImpactedResourcesItemsType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = ChangeEventCustomAttributesImpactedResourcesItems { + name, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ChangeEventCustomAttributesImpactedResourcesItemsVisitor) + } +} diff --git a/src/datadogV2/model/model_change_event_custom_attributes_impacted_resources_items_type.rs b/src/datadogV2/model/model_change_event_custom_attributes_impacted_resources_items_type.rs new file mode 100644 index 000000000..bbf9bec5d --- /dev/null +++ b/src/datadogV2/model/model_change_event_custom_attributes_impacted_resources_items_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum ChangeEventCustomAttributesImpactedResourcesItemsType { + SERVICE, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ChangeEventCustomAttributesImpactedResourcesItemsType { + fn to_string(&self) -> String { + match self { + Self::SERVICE => String::from("service"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ChangeEventCustomAttributesImpactedResourcesItemsType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for ChangeEventCustomAttributesImpactedResourcesItemsType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "service" => Self::SERVICE, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/tests/scenarios/cassettes/v1/dashboards/Create-a-new-dashboard-with-alert-graph-widget.frozen b/tests/scenarios/cassettes/v1/dashboards/Create-a-new-dashboard-with-alert-graph-widget.frozen index ea1f2ccb9..080276c3f 100644 --- a/tests/scenarios/cassettes/v1/dashboards/Create-a-new-dashboard-with-alert-graph-widget.frozen +++ b/tests/scenarios/cassettes/v1/dashboards/Create-a-new-dashboard-with-alert-graph-widget.frozen @@ -1 +1 @@ -2023-01-18T18:37:16.146Z \ No newline at end of file +2024-10-09T19:10:45.007Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v1/dashboards/Create-a-new-dashboard-with-alert-graph-widget.json b/tests/scenarios/cassettes/v1/dashboards/Create-a-new-dashboard-with-alert-graph-widget.json index 9294d265e..093a2b3e6 100644 --- a/tests/scenarios/cassettes/v1/dashboards/Create-a-new-dashboard-with-alert-graph-widget.json +++ b/tests/scenarios/cassettes/v1/dashboards/Create-a-new-dashboard-with-alert-graph-widget.json @@ -3,7 +3,7 @@ { "request": { "body": { - "string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Create_a_new_dashboard_with_alert_graph_widget-1674067036\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2,\"warning\":1},\"timeout_h\":24},\"priority\":3,\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"tags\":[\"test:testcreateanewdashboardwithalertgraphwidget1674067036\",\"env:ci\"],\"type\":\"log alert\"}", + "string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Create_a_new_dashboard_with_alert_graph_widget-1728501045\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2,\"warning\":1},\"timeout_h\":24},\"priority\":3,\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"tags\":[\"test:testcreateanewdashboardwithalertgraphwidget1728501045\",\"env:ci\"],\"type\":\"log alert\"}", "encoding": null }, "headers": { @@ -19,7 +19,7 @@ }, "response": { "body": { - "string": "{\"id\":108260299,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Create_a_new_dashboard_with_alert_graph_widget-1674067036\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testcreateanewdashboardwithalertgraphwidget1674067036\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"silenced\":{}},\"multi\":true,\"created_at\":1674067036000,\"created\":\"2023-01-18T18:37:16.358564+00:00\",\"modified\":\"2023-01-18T18:37:16.358564+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":null,\"handle\":\"frog@datadoghq.com\",\"email\":\"frog@datadoghq.com\",\"id\":1445416}}\n", + "string": "{\"id\":155777972,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Create_a_new_dashboard_with_alert_graph_widget-1728501045\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testcreateanewdashboardwithalertgraphwidget1728501045\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"groupby_simple_monitor\":false,\"silenced\":{}},\"multi\":true,\"created_at\":1728501045000,\"created\":\"2024-10-09T19:10:45.471411+00:00\",\"modified\":\"2024-10-09T19:10:45.471411+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"restriction_policy\":null,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"id\":2320499}}\n", "encoding": null }, "headers": { @@ -32,12 +32,12 @@ "message": "OK" } }, - "recorded_at": "Wed, 18 Jan 2023 18:37:16 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:45 GMT" }, { "request": { "body": { - "string": "{\"description\":\"\",\"is_read_only\":false,\"layout_type\":\"free\",\"notify_list\":[],\"template_variables\":[],\"title\":\"Test-Create_a_new_dashboard_with_alert_graph_widget-1674067036\",\"widgets\":[{\"definition\":{\"alert_id\":\"108260299\",\"time\":{},\"title\":\"\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"alert_graph\",\"viz_type\":\"timeseries\"},\"layout\":{\"height\":15,\"width\":47,\"x\":0,\"y\":0}}]}", + "string": "{\"description\":\"\",\"is_read_only\":false,\"layout_type\":\"free\",\"notify_list\":[],\"template_variables\":[],\"title\":\"Test-Create_a_new_dashboard_with_alert_graph_widget-1728501045\",\"widgets\":[{\"definition\":{\"alert_id\":\"155777972\",\"time\":{},\"title\":\"\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"alert_graph\",\"viz_type\":\"timeseries\"},\"layout\":{\"height\":15,\"width\":47,\"x\":0,\"y\":0}}]}", "encoding": null }, "headers": { @@ -53,7 +53,7 @@ }, "response": { "body": { - "string": "{\"notify_list\":[],\"description\":\"\",\"restricted_roles\":[],\"author_name\":null,\"template_variables\":[],\"is_read_only\":false,\"id\":\"tvp-85z-v2d\",\"title\":\"Test-Create_a_new_dashboard_with_alert_graph_widget-1674067036\",\"url\":\"/dashboard/tvp-85z-v2d/test-createanewdashboardwithalertgraphwidget-1674067036\",\"created_at\":\"2023-01-18T18:37:16.495648+00:00\",\"modified_at\":\"2023-01-18T18:37:16.495648+00:00\",\"author_handle\":\"frog@datadoghq.com\",\"widgets\":[{\"definition\":{\"title_size\":\"16\",\"viz_type\":\"timeseries\",\"title\":\"\",\"title_align\":\"left\",\"alert_id\":\"108260299\",\"time\":{},\"type\":\"alert_graph\"},\"layout\":{\"y\":0,\"width\":47,\"x\":0,\"height\":15},\"id\":236119153104762}],\"layout_type\":\"free\"}\n", + "string": "{\"id\":\"dma-bi2-bfq\",\"title\":\"Test-Create_a_new_dashboard_with_alert_graph_widget-1728501045\",\"description\":\"\",\"author_handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"author_name\":\"CI Account\",\"layout_type\":\"free\",\"url\":\"/dashboard/dma-bi2-bfq/test-createanewdashboardwithalertgraphwidget-1728501045\",\"is_read_only\":false,\"template_variables\":[],\"widgets\":[{\"definition\":{\"alert_id\":\"155777972\",\"time\":{},\"title\":\"\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"alert_graph\",\"viz_type\":\"timeseries\"},\"layout\":{\"height\":15,\"width\":47,\"x\":0,\"y\":0},\"id\":5577570364164388}],\"notify_list\":[],\"created_at\":\"2024-10-09T19:10:45.933616+00:00\",\"modified_at\":\"2024-10-09T19:10:45.933616+00:00\",\"restricted_roles\":[]}\n", "encoding": null }, "headers": { @@ -66,7 +66,7 @@ "message": "OK" } }, - "recorded_at": "Wed, 18 Jan 2023 18:37:16 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:45 GMT" }, { "request": { @@ -77,11 +77,11 @@ ] }, "method": "delete", - "uri": "https://api.datadoghq.com/api/v1/dashboard/tvp-85z-v2d" + "uri": "https://api.datadoghq.com/api/v1/dashboard/dma-bi2-bfq" }, "response": { "body": { - "string": "{\"deleted_dashboard_id\":\"tvp-85z-v2d\"}\n", + "string": "{\"deleted_dashboard_id\":\"dma-bi2-bfq\"}\n", "encoding": null }, "headers": { @@ -94,7 +94,7 @@ "message": "OK" } }, - "recorded_at": "Wed, 18 Jan 2023 18:37:16 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:45 GMT" }, { "request": { @@ -105,11 +105,11 @@ ] }, "method": "delete", - "uri": "https://api.datadoghq.com/api/v1/monitor/108260299" + "uri": "https://api.datadoghq.com/api/v1/monitor/155777972" }, "response": { "body": { - "string": "{\"deleted_monitor_id\":108260299}\n", + "string": "{\"deleted_monitor_id\":155777972}\n", "encoding": null }, "headers": { @@ -122,7 +122,7 @@ "message": "OK" } }, - "recorded_at": "Wed, 18 Jan 2023 18:37:16 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:45 GMT" } ], "recorded_with": "VCR 6.0.0" diff --git a/tests/scenarios/cassettes/v1/dashboards/Create-a-new-dashboard-with-alert-value-widget.frozen b/tests/scenarios/cassettes/v1/dashboards/Create-a-new-dashboard-with-alert-value-widget.frozen index 80f12ae04..7074fd03d 100644 --- a/tests/scenarios/cassettes/v1/dashboards/Create-a-new-dashboard-with-alert-value-widget.frozen +++ b/tests/scenarios/cassettes/v1/dashboards/Create-a-new-dashboard-with-alert-value-widget.frozen @@ -1 +1 @@ -2023-01-18T18:37:16.878Z \ No newline at end of file +2024-10-09T19:10:46.917Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v1/dashboards/Create-a-new-dashboard-with-alert-value-widget.json b/tests/scenarios/cassettes/v1/dashboards/Create-a-new-dashboard-with-alert-value-widget.json index 0412ccd19..3e3aaa952 100644 --- a/tests/scenarios/cassettes/v1/dashboards/Create-a-new-dashboard-with-alert-value-widget.json +++ b/tests/scenarios/cassettes/v1/dashboards/Create-a-new-dashboard-with-alert-value-widget.json @@ -3,7 +3,7 @@ { "request": { "body": { - "string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Create_a_new_dashboard_with_alert_value_widget-1674067036\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2,\"warning\":1},\"timeout_h\":24},\"priority\":3,\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"tags\":[\"test:testcreateanewdashboardwithalertvaluewidget1674067036\",\"env:ci\"],\"type\":\"log alert\"}", + "string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Create_a_new_dashboard_with_alert_value_widget-1728501046\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2,\"warning\":1},\"timeout_h\":24},\"priority\":3,\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"tags\":[\"test:testcreateanewdashboardwithalertvaluewidget1728501046\",\"env:ci\"],\"type\":\"log alert\"}", "encoding": null }, "headers": { @@ -19,7 +19,7 @@ }, "response": { "body": { - "string": "{\"id\":108260300,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Create_a_new_dashboard_with_alert_value_widget-1674067036\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testcreateanewdashboardwithalertvaluewidget1674067036\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"silenced\":{}},\"multi\":true,\"created_at\":1674067037000,\"created\":\"2023-01-18T18:37:17.013180+00:00\",\"modified\":\"2023-01-18T18:37:17.013180+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":null,\"handle\":\"frog@datadoghq.com\",\"email\":\"frog@datadoghq.com\",\"id\":1445416}}\n", + "string": "{\"id\":155777973,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Create_a_new_dashboard_with_alert_value_widget-1728501046\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testcreateanewdashboardwithalertvaluewidget1728501046\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"groupby_simple_monitor\":false,\"silenced\":{}},\"multi\":true,\"created_at\":1728501047000,\"created\":\"2024-10-09T19:10:47.294819+00:00\",\"modified\":\"2024-10-09T19:10:47.294819+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"restriction_policy\":null,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"id\":2320499}}\n", "encoding": null }, "headers": { @@ -32,12 +32,12 @@ "message": "OK" } }, - "recorded_at": "Wed, 18 Jan 2023 18:37:16 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:46 GMT" }, { "request": { "body": { - "string": "{\"description\":\"\",\"is_read_only\":false,\"layout_type\":\"free\",\"notify_list\":[],\"template_variables\":[],\"title\":\"Test-Create_a_new_dashboard_with_alert_value_widget-1674067036\",\"widgets\":[{\"definition\":{\"alert_id\":\"108260300\",\"precision\":2,\"text_align\":\"left\",\"title\":\"\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"alert_value\",\"unit\":\"auto\"},\"layout\":{\"height\":8,\"width\":15,\"x\":0,\"y\":0}}]}", + "string": "{\"description\":\"\",\"is_read_only\":false,\"layout_type\":\"free\",\"notify_list\":[],\"template_variables\":[],\"title\":\"Test-Create_a_new_dashboard_with_alert_value_widget-1728501046\",\"widgets\":[{\"definition\":{\"alert_id\":\"155777973\",\"precision\":2,\"text_align\":\"left\",\"title\":\"\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"alert_value\",\"unit\":\"auto\"},\"layout\":{\"height\":8,\"width\":15,\"x\":0,\"y\":0}}]}", "encoding": null }, "headers": { @@ -53,7 +53,7 @@ }, "response": { "body": { - "string": "{\"notify_list\":[],\"description\":\"\",\"restricted_roles\":[],\"author_name\":null,\"template_variables\":[],\"is_read_only\":false,\"id\":\"ess-8yc-y8y\",\"title\":\"Test-Create_a_new_dashboard_with_alert_value_widget-1674067036\",\"url\":\"/dashboard/ess-8yc-y8y/test-createanewdashboardwithalertvaluewidget-1674067036\",\"created_at\":\"2023-01-18T18:37:17.145823+00:00\",\"modified_at\":\"2023-01-18T18:37:17.145823+00:00\",\"author_handle\":\"frog@datadoghq.com\",\"widgets\":[{\"definition\":{\"title_size\":\"16\",\"title\":\"\",\"title_align\":\"left\",\"text_align\":\"left\",\"precision\":2,\"alert_id\":\"108260300\",\"type\":\"alert_value\",\"unit\":\"auto\"},\"layout\":{\"y\":0,\"width\":15,\"x\":0,\"height\":8},\"id\":3516493079797108}],\"layout_type\":\"free\"}\n", + "string": "{\"id\":\"jfs-i5n-8pc\",\"title\":\"Test-Create_a_new_dashboard_with_alert_value_widget-1728501046\",\"description\":\"\",\"author_handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"author_name\":\"CI Account\",\"layout_type\":\"free\",\"url\":\"/dashboard/jfs-i5n-8pc/test-createanewdashboardwithalertvaluewidget-1728501046\",\"is_read_only\":false,\"template_variables\":[],\"widgets\":[{\"definition\":{\"alert_id\":\"155777973\",\"precision\":2,\"text_align\":\"left\",\"title\":\"\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"alert_value\",\"unit\":\"auto\"},\"layout\":{\"height\":8,\"width\":15,\"x\":0,\"y\":0},\"id\":4308194848648575}],\"notify_list\":[],\"created_at\":\"2024-10-09T19:10:47.712161+00:00\",\"modified_at\":\"2024-10-09T19:10:47.712161+00:00\",\"restricted_roles\":[]}\n", "encoding": null }, "headers": { @@ -66,7 +66,7 @@ "message": "OK" } }, - "recorded_at": "Wed, 18 Jan 2023 18:37:16 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:46 GMT" }, { "request": { @@ -77,11 +77,11 @@ ] }, "method": "delete", - "uri": "https://api.datadoghq.com/api/v1/dashboard/ess-8yc-y8y" + "uri": "https://api.datadoghq.com/api/v1/dashboard/jfs-i5n-8pc" }, "response": { "body": { - "string": "{\"deleted_dashboard_id\":\"ess-8yc-y8y\"}\n", + "string": "{\"deleted_dashboard_id\":\"jfs-i5n-8pc\"}\n", "encoding": null }, "headers": { @@ -94,7 +94,7 @@ "message": "OK" } }, - "recorded_at": "Wed, 18 Jan 2023 18:37:16 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:46 GMT" }, { "request": { @@ -105,11 +105,11 @@ ] }, "method": "delete", - "uri": "https://api.datadoghq.com/api/v1/monitor/108260300" + "uri": "https://api.datadoghq.com/api/v1/monitor/155777973" }, "response": { "body": { - "string": "{\"deleted_monitor_id\":108260300}\n", + "string": "{\"deleted_monitor_id\":155777973}\n", "encoding": null }, "headers": { @@ -122,7 +122,7 @@ "message": "OK" } }, - "recorded_at": "Wed, 18 Jan 2023 18:37:16 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:46 GMT" } ], "recorded_with": "VCR 6.0.0" diff --git a/tests/scenarios/cassettes/v1/downtimes/Schedule-a-monitor-downtime-returns-OK-response.frozen b/tests/scenarios/cassettes/v1/downtimes/Schedule-a-monitor-downtime-returns-OK-response.frozen index 53b28bc78..4b2e0f4a4 100644 --- a/tests/scenarios/cassettes/v1/downtimes/Schedule-a-monitor-downtime-returns-OK-response.frozen +++ b/tests/scenarios/cassettes/v1/downtimes/Schedule-a-monitor-downtime-returns-OK-response.frozen @@ -1 +1 @@ -2023-01-18T18:37:17.507Z \ No newline at end of file +2024-10-09T19:10:48.738Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v1/downtimes/Schedule-a-monitor-downtime-returns-OK-response.json b/tests/scenarios/cassettes/v1/downtimes/Schedule-a-monitor-downtime-returns-OK-response.json index 08b4b1681..25199dd79 100644 --- a/tests/scenarios/cassettes/v1/downtimes/Schedule-a-monitor-downtime-returns-OK-response.json +++ b/tests/scenarios/cassettes/v1/downtimes/Schedule-a-monitor-downtime-returns-OK-response.json @@ -3,7 +3,7 @@ { "request": { "body": { - "string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Schedule_a_monitor_downtime_returns_OK_response-1674067037\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2,\"warning\":1},\"timeout_h\":24},\"priority\":3,\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"tags\":[\"test:testscheduleamonitordowntimereturnsokresponse1674067037\",\"env:ci\"],\"type\":\"log alert\"}", + "string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Schedule_a_monitor_downtime_returns_OK_response-1728501048\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2,\"warning\":1},\"timeout_h\":24},\"priority\":3,\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"tags\":[\"test:testscheduleamonitordowntimereturnsokresponse1728501048\",\"env:ci\"],\"type\":\"log alert\"}", "encoding": null }, "headers": { @@ -19,7 +19,7 @@ }, "response": { "body": { - "string": "{\"id\":108260301,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Schedule_a_monitor_downtime_returns_OK_response-1674067037\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testscheduleamonitordowntimereturnsokresponse1674067037\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"silenced\":{}},\"multi\":true,\"created_at\":1674067037000,\"created\":\"2023-01-18T18:37:17.701290+00:00\",\"modified\":\"2023-01-18T18:37:17.701290+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":null,\"handle\":\"frog@datadoghq.com\",\"email\":\"frog@datadoghq.com\",\"id\":1445416}}\n", + "string": "{\"id\":155777976,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Schedule_a_monitor_downtime_returns_OK_response-1728501048\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testscheduleamonitordowntimereturnsokresponse1728501048\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"groupby_simple_monitor\":false,\"silenced\":{}},\"multi\":true,\"created_at\":1728501049000,\"created\":\"2024-10-09T19:10:49.823767+00:00\",\"modified\":\"2024-10-09T19:10:49.823767+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"restriction_policy\":null,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"id\":2320499}}\n", "encoding": null }, "headers": { @@ -32,12 +32,12 @@ "message": "OK" } }, - "recorded_at": "Wed, 18 Jan 2023 18:37:17 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:48 GMT" }, { "request": { "body": { - "string": "{\"message\":\"Test-Schedule_a_monitor_downtime_returns_OK_response-1674067037\",\"monitor_id\":108260301,\"scope\":[\"test:testscheduleamonitordowntimereturnsokresponse1674067037\"],\"start\":1674067037,\"timezone\":\"Etc/UTC\"}", + "string": "{\"message\":\"Test-Schedule_a_monitor_downtime_returns_OK_response-1728501048\",\"monitor_id\":155777976,\"scope\":[\"test:testscheduleamonitordowntimereturnsokresponse1728501048\"],\"start\":1728501048,\"timezone\":\"Etc/UTC\"}", "encoding": null }, "headers": { @@ -53,7 +53,7 @@ }, "response": { "body": { - "string": "{\"id\":2598558218,\"monitor_id\":108260301,\"org_id\":321813,\"start\":1674067037,\"end\":null,\"canceled\":null,\"created\":1674067037,\"modified\":1674067037,\"message\":\"Test-Schedule_a_monitor_downtime_returns_OK_response-1674067037\",\"active\":true,\"disabled\":false,\"recurrence\":null,\"timezone\":\"Etc/UTC\",\"parent_id\":null,\"child_id\":null,\"creator_id\":1445416,\"updater_id\":null,\"downtime_type\":2,\"monitor_tags\":[\"*\"],\"mute_first_recovery_notification\":false,\"scope\":[\"test:testscheduleamonitordowntimereturnsokresponse1674067037\"]}\n", + "string": "{\"id\":4428559092,\"monitor_id\":155777976,\"org_id\":321813,\"start\":1728501048,\"end\":null,\"canceled\":null,\"created\":1728501050,\"modified\":1728501050,\"message\":\"Test-Schedule_a_monitor_downtime_returns_OK_response-1728501048\",\"active\":true,\"disabled\":false,\"recurrence\":null,\"timezone\":\"Etc/UTC\",\"parent_id\":null,\"child_id\":null,\"creator_id\":2320499,\"updater_id\":null,\"downtime_type\":2,\"status\":\"active\",\"monitor_tags\":[\"*\"],\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"notify_end_states\":[\"alert\",\"no data\",\"warn\"],\"uuid\":\"3c71a4ea-c643-4321-977b-854c7014643d\",\"scope\":[\"test:testscheduleamonitordowntimereturnsokresponse1728501048\"]}\n", "encoding": null }, "headers": { @@ -66,7 +66,7 @@ "message": "OK" } }, - "recorded_at": "Wed, 18 Jan 2023 18:37:17 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:48 GMT" }, { "request": { @@ -77,7 +77,7 @@ ] }, "method": "delete", - "uri": "https://api.datadoghq.com/api/v1/downtime/2598558218" + "uri": "https://api.datadoghq.com/api/v1/downtime/4428559092" }, "response": { "body": { @@ -94,7 +94,7 @@ "message": "No Content" } }, - "recorded_at": "Wed, 18 Jan 2023 18:37:17 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:48 GMT" }, { "request": { @@ -105,11 +105,11 @@ ] }, "method": "delete", - "uri": "https://api.datadoghq.com/api/v1/monitor/108260301" + "uri": "https://api.datadoghq.com/api/v1/monitor/155777976" }, "response": { "body": { - "string": "{\"deleted_monitor_id\":108260301}\n", + "string": "{\"deleted_monitor_id\":155777976}\n", "encoding": null }, "headers": { @@ -122,7 +122,7 @@ "message": "OK" } }, - "recorded_at": "Wed, 18 Jan 2023 18:37:17 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:48 GMT" } ], "recorded_with": "VCR 6.0.0" diff --git a/tests/scenarios/cassettes/v1/monitors/Check-if-a-monitor-can-be-deleted-returns-OK-response.frozen b/tests/scenarios/cassettes/v1/monitors/Check-if-a-monitor-can-be-deleted-returns-OK-response.frozen index bdefbfef1..d059f246f 100644 --- a/tests/scenarios/cassettes/v1/monitors/Check-if-a-monitor-can-be-deleted-returns-OK-response.frozen +++ b/tests/scenarios/cassettes/v1/monitors/Check-if-a-monitor-can-be-deleted-returns-OK-response.frozen @@ -1 +1 @@ -2023-01-18T18:37:18.314Z \ No newline at end of file +2024-10-09T19:10:51.425Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v1/monitors/Check-if-a-monitor-can-be-deleted-returns-OK-response.json b/tests/scenarios/cassettes/v1/monitors/Check-if-a-monitor-can-be-deleted-returns-OK-response.json index 15a2825af..f076135da 100644 --- a/tests/scenarios/cassettes/v1/monitors/Check-if-a-monitor-can-be-deleted-returns-OK-response.json +++ b/tests/scenarios/cassettes/v1/monitors/Check-if-a-monitor-can-be-deleted-returns-OK-response.json @@ -3,7 +3,7 @@ { "request": { "body": { - "string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Check_if_a_monitor_can_be_deleted_returns_OK_response-1674067038\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2,\"warning\":1},\"timeout_h\":24},\"priority\":3,\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"tags\":[\"test:testcheckifamonitorcanbedeletedreturnsokresponse1674067038\",\"env:ci\"],\"type\":\"log alert\"}", + "string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Check_if_a_monitor_can_be_deleted_returns_OK_response-1728501051\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2,\"warning\":1},\"timeout_h\":24},\"priority\":3,\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"tags\":[\"test:testcheckifamonitorcanbedeletedreturnsokresponse1728501051\",\"env:ci\"],\"type\":\"log alert\"}", "encoding": null }, "headers": { @@ -19,7 +19,7 @@ }, "response": { "body": { - "string": "{\"id\":108260302,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Check_if_a_monitor_can_be_deleted_returns_OK_response-1674067038\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testcheckifamonitorcanbedeletedreturnsokresponse1674067038\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"silenced\":{}},\"multi\":true,\"created_at\":1674067038000,\"created\":\"2023-01-18T18:37:18.431658+00:00\",\"modified\":\"2023-01-18T18:37:18.431658+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":null,\"handle\":\"frog@datadoghq.com\",\"email\":\"frog@datadoghq.com\",\"id\":1445416}}\n", + "string": "{\"id\":155777984,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Check_if_a_monitor_can_be_deleted_returns_OK_response-1728501051\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testcheckifamonitorcanbedeletedreturnsokresponse1728501051\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"groupby_simple_monitor\":false,\"silenced\":{}},\"multi\":true,\"created_at\":1728501051000,\"created\":\"2024-10-09T19:10:51.782687+00:00\",\"modified\":\"2024-10-09T19:10:51.782687+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"restriction_policy\":null,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"id\":2320499}}\n", "encoding": null }, "headers": { @@ -32,7 +32,7 @@ "message": "OK" } }, - "recorded_at": "Wed, 18 Jan 2023 18:37:18 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:51 GMT" }, { "request": { @@ -43,11 +43,11 @@ ] }, "method": "get", - "uri": "https://api.datadoghq.com/api/v1/monitor/can_delete?monitor_ids=108260302" + "uri": "https://api.datadoghq.com/api/v1/monitor/can_delete?monitor_ids=155777984" }, "response": { "body": { - "string": "{\"data\":{\"ok\":[108260302]},\"errors\":null}\n", + "string": "{\"data\":{\"ok\":[155777984]},\"errors\":null}\n", "encoding": null }, "headers": { @@ -60,7 +60,7 @@ "message": "OK" } }, - "recorded_at": "Wed, 18 Jan 2023 18:37:18 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:51 GMT" }, { "request": { @@ -71,11 +71,11 @@ ] }, "method": "delete", - "uri": "https://api.datadoghq.com/api/v1/monitor/108260302" + "uri": "https://api.datadoghq.com/api/v1/monitor/155777984" }, "response": { "body": { - "string": "{\"deleted_monitor_id\":108260302}\n", + "string": "{\"deleted_monitor_id\":155777984}\n", "encoding": null }, "headers": { @@ -88,7 +88,7 @@ "message": "OK" } }, - "recorded_at": "Wed, 18 Jan 2023 18:37:18 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:51 GMT" } ], "recorded_with": "VCR 6.0.0" diff --git a/tests/scenarios/cassettes/v1/monitors/Delete-a-monitor-returns-OK-response.frozen b/tests/scenarios/cassettes/v1/monitors/Delete-a-monitor-returns-OK-response.frozen index 06daabc81..a89f3003a 100644 --- a/tests/scenarios/cassettes/v1/monitors/Delete-a-monitor-returns-OK-response.frozen +++ b/tests/scenarios/cassettes/v1/monitors/Delete-a-monitor-returns-OK-response.frozen @@ -1 +1 @@ -2023-01-18T18:37:18.880Z \ No newline at end of file +2024-10-09T19:10:52.647Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v1/monitors/Delete-a-monitor-returns-OK-response.json b/tests/scenarios/cassettes/v1/monitors/Delete-a-monitor-returns-OK-response.json index 317dc7c80..a9005c06e 100644 --- a/tests/scenarios/cassettes/v1/monitors/Delete-a-monitor-returns-OK-response.json +++ b/tests/scenarios/cassettes/v1/monitors/Delete-a-monitor-returns-OK-response.json @@ -3,7 +3,7 @@ { "request": { "body": { - "string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Delete_a_monitor_returns_OK_response-1674067038\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2,\"warning\":1},\"timeout_h\":24},\"priority\":3,\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"tags\":[\"test:testdeleteamonitorreturnsokresponse1674067038\",\"env:ci\"],\"type\":\"log alert\"}", + "string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Delete_a_monitor_returns_OK_response-1728501052\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2,\"warning\":1},\"timeout_h\":24},\"priority\":3,\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"tags\":[\"test:testdeleteamonitorreturnsokresponse1728501052\",\"env:ci\"],\"type\":\"log alert\"}", "encoding": null }, "headers": { @@ -19,7 +19,7 @@ }, "response": { "body": { - "string": "{\"id\":108260303,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Delete_a_monitor_returns_OK_response-1674067038\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testdeleteamonitorreturnsokresponse1674067038\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"silenced\":{}},\"multi\":true,\"created_at\":1674067039000,\"created\":\"2023-01-18T18:37:19.000343+00:00\",\"modified\":\"2023-01-18T18:37:19.000343+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":null,\"handle\":\"frog@datadoghq.com\",\"email\":\"frog@datadoghq.com\",\"id\":1445416}}\n", + "string": "{\"id\":155777995,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Delete_a_monitor_returns_OK_response-1728501052\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testdeleteamonitorreturnsokresponse1728501052\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"groupby_simple_monitor\":false,\"silenced\":{}},\"multi\":true,\"created_at\":1728501053000,\"created\":\"2024-10-09T19:10:53.021211+00:00\",\"modified\":\"2024-10-09T19:10:53.021211+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"restriction_policy\":null,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"id\":2320499}}\n", "encoding": null }, "headers": { @@ -32,7 +32,7 @@ "message": "OK" } }, - "recorded_at": "Wed, 18 Jan 2023 18:37:18 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:52 GMT" }, { "request": { @@ -43,11 +43,11 @@ ] }, "method": "delete", - "uri": "https://api.datadoghq.com/api/v1/monitor/108260303" + "uri": "https://api.datadoghq.com/api/v1/monitor/155777995" }, "response": { "body": { - "string": "{\"deleted_monitor_id\":108260303}\n", + "string": "{\"deleted_monitor_id\":155777995}\n", "encoding": null }, "headers": { @@ -60,7 +60,7 @@ "message": "OK" } }, - "recorded_at": "Wed, 18 Jan 2023 18:37:18 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:52 GMT" }, { "request": { @@ -71,7 +71,7 @@ ] }, "method": "delete", - "uri": "https://api.datadoghq.com/api/v1/monitor/108260303" + "uri": "https://api.datadoghq.com/api/v1/monitor/155777995" }, "response": { "body": { @@ -88,7 +88,7 @@ "message": "Not Found" } }, - "recorded_at": "Wed, 18 Jan 2023 18:37:18 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:52 GMT" } ], "recorded_with": "VCR 6.0.0" diff --git a/tests/scenarios/cassettes/v1/monitors/Edit-a-monitor-returns-OK-response.frozen b/tests/scenarios/cassettes/v1/monitors/Edit-a-monitor-returns-OK-response.frozen index 981d358e3..b83f5dae8 100644 --- a/tests/scenarios/cassettes/v1/monitors/Edit-a-monitor-returns-OK-response.frozen +++ b/tests/scenarios/cassettes/v1/monitors/Edit-a-monitor-returns-OK-response.frozen @@ -1 +1 @@ -2024-06-20T19:37:04.361Z \ No newline at end of file +2024-10-09T19:10:53.885Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v1/monitors/Edit-a-monitor-returns-OK-response.json b/tests/scenarios/cassettes/v1/monitors/Edit-a-monitor-returns-OK-response.json index 0aea43a4e..56e41d92d 100644 --- a/tests/scenarios/cassettes/v1/monitors/Edit-a-monitor-returns-OK-response.json +++ b/tests/scenarios/cassettes/v1/monitors/Edit-a-monitor-returns-OK-response.json @@ -3,7 +3,7 @@ { "request": { "body": { - "string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Edit_a_monitor_returns_OK_response-1718912224\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2,\"warning\":1},\"timeout_h\":24},\"priority\":3,\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"tags\":[\"test:testeditamonitorreturnsokresponse1718912224\",\"env:ci\"],\"type\":\"log alert\"}", + "string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Edit_a_monitor_returns_OK_response-1728501053\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2,\"warning\":1},\"timeout_h\":24},\"priority\":3,\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"tags\":[\"test:testeditamonitorreturnsokresponse1728501053\",\"env:ci\"],\"type\":\"log alert\"}", "encoding": null }, "headers": { @@ -19,7 +19,7 @@ }, "response": { "body": { - "string": "{\"id\":147580793,\"org_id\":237503,\"type\":\"log alert\",\"name\":\"Test-Edit_a_monitor_returns_OK_response-1718912224\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testeditamonitorreturnsokresponse1718912224\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"silenced\":{}},\"multi\":true,\"created_at\":1718912224000,\"created\":\"2024-06-20T19:37:04.686145+00:00\",\"modified\":\"2024-06-20T19:37:04.686145+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"restriction_policy\":null,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":\"Carl Martensen\",\"handle\":\"carl.martensen@datadoghq.com\",\"email\":\"carl.martensen@datadoghq.com\",\"id\":1078685}}\n", + "string": "{\"id\":155778004,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Edit_a_monitor_returns_OK_response-1728501053\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testeditamonitorreturnsokresponse1728501053\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"groupby_simple_monitor\":false,\"silenced\":{}},\"multi\":true,\"created_at\":1728501054000,\"created\":\"2024-10-09T19:10:54.256878+00:00\",\"modified\":\"2024-10-09T19:10:54.256878+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"restriction_policy\":null,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"id\":2320499}}\n", "encoding": null }, "headers": { @@ -32,12 +32,12 @@ "message": "OK" } }, - "recorded_at": "Thu, 20 Jun 2024 19:37:04 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:53 GMT" }, { "request": { "body": { - "string": "{\"name\":\"Test-Edit_a_monitor_returns_OK_response-1718912224-updated\",\"options\":{\"evaluation_delay\":null,\"new_group_delay\":600,\"new_host_delay\":null,\"renotify_interval\":null,\"thresholds\":{\"critical\":2,\"warning\":null},\"timeout_h\":null},\"priority\":null}", + "string": "{\"name\":\"Test-Edit_a_monitor_returns_OK_response-1728501053-updated\",\"options\":{\"evaluation_delay\":null,\"new_group_delay\":600,\"new_host_delay\":null,\"renotify_interval\":null,\"thresholds\":{\"critical\":2,\"warning\":null},\"timeout_h\":null},\"priority\":null}", "encoding": null }, "headers": { @@ -49,11 +49,11 @@ ] }, "method": "put", - "uri": "https://api.datadoghq.com/api/v1/monitor/147580793" + "uri": "https://api.datadoghq.com/api/v1/monitor/155778004" }, "response": { "body": { - "string": "{\"id\":147580793,\"org_id\":237503,\"type\":\"log alert\",\"name\":\"Test-Edit_a_monitor_returns_OK_response-1718912224-updated\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testeditamonitorreturnsokresponse1718912224\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"evaluation_delay\":null,\"new_group_delay\":600,\"new_host_delay\":null,\"renotify_interval\":null,\"thresholds\":{\"critical\":2.0},\"timeout_h\":null,\"notify_no_data\":false,\"notify_audit\":false,\"include_tags\":true,\"groupby_simple_monitor\":false,\"silenced\":{}},\"multi\":true,\"created_at\":1718912224000,\"created\":\"2024-06-20T19:37:04.686145+00:00\",\"modified\":\"2024-06-20T19:37:05.129654+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":null,\"restriction_policy\":null,\"overall_state_modified\":null,\"overall_state\":\"No Data\"}\n", + "string": "{\"id\":155778004,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Edit_a_monitor_returns_OK_response-1728501053-updated\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testeditamonitorreturnsokresponse1728501053\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"evaluation_delay\":null,\"new_group_delay\":600,\"new_host_delay\":null,\"renotify_interval\":null,\"thresholds\":{\"critical\":2.0},\"timeout_h\":null,\"notify_no_data\":false,\"notify_audit\":false,\"include_tags\":true,\"groupby_simple_monitor\":false,\"silenced\":{}},\"multi\":true,\"created_at\":1728501054000,\"created\":\"2024-10-09T19:10:54.256878+00:00\",\"modified\":\"2024-10-09T19:10:54.740903+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":null,\"restriction_policy\":null,\"overall_state_modified\":null,\"overall_state\":\"No Data\"}\n", "encoding": null }, "headers": { @@ -66,7 +66,7 @@ "message": "OK" } }, - "recorded_at": "Thu, 20 Jun 2024 19:37:04 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:53 GMT" }, { "request": { @@ -77,11 +77,11 @@ ] }, "method": "delete", - "uri": "https://api.datadoghq.com/api/v1/monitor/147580793" + "uri": "https://api.datadoghq.com/api/v1/monitor/155778004" }, "response": { "body": { - "string": "{\"deleted_monitor_id\":147580793}\n", + "string": "{\"deleted_monitor_id\":155778004}\n", "encoding": null }, "headers": { @@ -94,7 +94,7 @@ "message": "OK" } }, - "recorded_at": "Thu, 20 Jun 2024 19:37:04 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:53 GMT" } ], "recorded_with": "VCR 6.0.0" diff --git a/tests/scenarios/cassettes/v1/monitors/Get-a-monitor-s-details-returns-OK-response.frozen b/tests/scenarios/cassettes/v1/monitors/Get-a-monitor-s-details-returns-OK-response.frozen index ec45a2b56..039b1cf8f 100644 --- a/tests/scenarios/cassettes/v1/monitors/Get-a-monitor-s-details-returns-OK-response.frozen +++ b/tests/scenarios/cassettes/v1/monitors/Get-a-monitor-s-details-returns-OK-response.frozen @@ -1 +1 @@ -2023-05-22T17:02:26.784Z \ No newline at end of file +2024-10-09T19:10:55.263Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v1/monitors/Get-a-monitor-s-details-returns-OK-response.json b/tests/scenarios/cassettes/v1/monitors/Get-a-monitor-s-details-returns-OK-response.json index 998d9edeb..a1769bb9b 100644 --- a/tests/scenarios/cassettes/v1/monitors/Get-a-monitor-s-details-returns-OK-response.json +++ b/tests/scenarios/cassettes/v1/monitors/Get-a-monitor-s-details-returns-OK-response.json @@ -3,7 +3,7 @@ { "request": { "body": { - "string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Get_a_monitor_s_details_returns_OK_response-1684774946\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2,\"warning\":1},\"timeout_h\":24},\"priority\":3,\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"tags\":[\"test:testgetamonitorsdetailsreturnsokresponse1684774946\",\"env:ci\"],\"type\":\"log alert\"}", + "string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Get_a_monitor_s_details_returns_OK_response-1728501055\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2,\"warning\":1},\"timeout_h\":24},\"priority\":3,\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"tags\":[\"test:testgetamonitorsdetailsreturnsokresponse1728501055\",\"env:ci\"],\"type\":\"log alert\"}", "encoding": null }, "headers": { @@ -19,7 +19,7 @@ }, "response": { "body": { - "string": "{\"id\":119735290,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Get_a_monitor_s_details_returns_OK_response-1684774946\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testgetamonitorsdetailsreturnsokresponse1684774946\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"silenced\":{}},\"multi\":true,\"created_at\":1684774946000,\"created\":\"2023-05-22T17:02:26.996650+00:00\",\"modified\":\"2023-05-22T17:02:26.996650+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":null,\"handle\":\"frog@datadoghq.com\",\"email\":\"frog@datadoghq.com\",\"id\":1445416}}\n", + "string": "{\"id\":155778013,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Get_a_monitor_s_details_returns_OK_response-1728501055\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testgetamonitorsdetailsreturnsokresponse1728501055\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"groupby_simple_monitor\":false,\"silenced\":{}},\"multi\":true,\"created_at\":1728501055000,\"created\":\"2024-10-09T19:10:55.618391+00:00\",\"modified\":\"2024-10-09T19:10:55.618391+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"restriction_policy\":null,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"id\":2320499}}\n", "encoding": null }, "headers": { @@ -32,7 +32,7 @@ "message": "OK" } }, - "recorded_at": "Mon, 22 May 2023 17:02:26 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:55 GMT" }, { "request": { @@ -43,11 +43,11 @@ ] }, "method": "get", - "uri": "https://api.datadoghq.com/api/v1/monitor/119735290?with_downtimes=true" + "uri": "https://api.datadoghq.com/api/v1/monitor/155778013?with_downtimes=true" }, "response": { "body": { - "string": "{\"id\":119735290,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Get_a_monitor_s_details_returns_OK_response-1684774946\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testgetamonitorsdetailsreturnsokresponse1684774946\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"silenced\":{}},\"multi\":true,\"created_at\":1684774946000,\"created\":\"2023-05-22T17:02:26.996650+00:00\",\"modified\":\"2023-05-22T17:02:26.996650+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":null,\"handle\":\"frog@datadoghq.com\",\"email\":\"frog@datadoghq.com\",\"id\":1445416},\"matching_downtimes\":[]}\n", + "string": "{\"id\":155778013,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Get_a_monitor_s_details_returns_OK_response-1728501055\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testgetamonitorsdetailsreturnsokresponse1728501055\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"groupby_simple_monitor\":false,\"silenced\":{}},\"multi\":true,\"created_at\":1728501055000,\"created\":\"2024-10-09T19:10:55.618391+00:00\",\"modified\":\"2024-10-09T19:10:55.618391+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":\"CI Account\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"id\":2320499},\"matching_downtimes\":[]}\n", "encoding": null }, "headers": { @@ -60,7 +60,7 @@ "message": "OK" } }, - "recorded_at": "Mon, 22 May 2023 17:02:26 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:55 GMT" }, { "request": { @@ -71,11 +71,11 @@ ] }, "method": "delete", - "uri": "https://api.datadoghq.com/api/v1/monitor/119735290" + "uri": "https://api.datadoghq.com/api/v1/monitor/155778013" }, "response": { "body": { - "string": "{\"deleted_monitor_id\":119735290}\n", + "string": "{\"deleted_monitor_id\":155778013}\n", "encoding": null }, "headers": { @@ -88,7 +88,7 @@ "message": "OK" } }, - "recorded_at": "Mon, 22 May 2023 17:02:26 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:55 GMT" } ], "recorded_with": "VCR 6.0.0" diff --git a/tests/scenarios/cassettes/v1/monitors/Validate-an-existing-monitor-returns-Invalid-JSON-response.frozen b/tests/scenarios/cassettes/v1/monitors/Validate-an-existing-monitor-returns-Invalid-JSON-response.frozen index c29a2d2e9..fad942179 100644 --- a/tests/scenarios/cassettes/v1/monitors/Validate-an-existing-monitor-returns-Invalid-JSON-response.frozen +++ b/tests/scenarios/cassettes/v1/monitors/Validate-an-existing-monitor-returns-Invalid-JSON-response.frozen @@ -1 +1 @@ -2023-01-18T18:37:20.085Z \ No newline at end of file +2024-10-09T19:10:56.540Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v1/monitors/Validate-an-existing-monitor-returns-Invalid-JSON-response.json b/tests/scenarios/cassettes/v1/monitors/Validate-an-existing-monitor-returns-Invalid-JSON-response.json index 134f33571..45aedd74a 100644 --- a/tests/scenarios/cassettes/v1/monitors/Validate-an-existing-monitor-returns-Invalid-JSON-response.json +++ b/tests/scenarios/cassettes/v1/monitors/Validate-an-existing-monitor-returns-Invalid-JSON-response.json @@ -3,7 +3,7 @@ { "request": { "body": { - "string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Validate_an_existing_monitor_returns_Invalid_JSON_response-1674067040\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2,\"warning\":1},\"timeout_h\":24},\"priority\":3,\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"tags\":[\"test:testvalidateanexistingmonitorreturnsinvalidjsonresponse1674067040\",\"env:ci\"],\"type\":\"log alert\"}", + "string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Validate_an_existing_monitor_returns_Invalid_JSON_response-1728501056\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2,\"warning\":1},\"timeout_h\":24},\"priority\":3,\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"tags\":[\"test:testvalidateanexistingmonitorreturnsinvalidjsonresponse1728501056\",\"env:ci\"],\"type\":\"log alert\"}", "encoding": null }, "headers": { @@ -19,7 +19,7 @@ }, "response": { "body": { - "string": "{\"id\":108260306,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Validate_an_existing_monitor_returns_Invalid_JSON_response-1674067040\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testvalidateanexistingmonitorreturnsinvalidjsonresponse1674067040\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"silenced\":{}},\"multi\":true,\"created_at\":1674067040000,\"created\":\"2023-01-18T18:37:20.200427+00:00\",\"modified\":\"2023-01-18T18:37:20.200427+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":null,\"handle\":\"frog@datadoghq.com\",\"email\":\"frog@datadoghq.com\",\"id\":1445416}}\n", + "string": "{\"id\":155778018,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Validate_an_existing_monitor_returns_Invalid_JSON_response-1728501056\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testvalidateanexistingmonitorreturnsinvalidjsonresponse1728501056\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"groupby_simple_monitor\":false,\"silenced\":{}},\"multi\":true,\"created_at\":1728501056000,\"created\":\"2024-10-09T19:10:56.932037+00:00\",\"modified\":\"2024-10-09T19:10:56.932037+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"restriction_policy\":null,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"id\":2320499}}\n", "encoding": null }, "headers": { @@ -32,7 +32,7 @@ "message": "OK" } }, - "recorded_at": "Wed, 18 Jan 2023 18:37:20 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:56 GMT" }, { "request": { @@ -49,7 +49,7 @@ ] }, "method": "post", - "uri": "https://api.datadoghq.com/api/v1/monitor/108260306/validate" + "uri": "https://api.datadoghq.com/api/v1/monitor/155778018/validate" }, "response": { "body": { @@ -66,7 +66,7 @@ "message": "Bad Request" } }, - "recorded_at": "Wed, 18 Jan 2023 18:37:20 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:56 GMT" }, { "request": { @@ -77,11 +77,11 @@ ] }, "method": "delete", - "uri": "https://api.datadoghq.com/api/v1/monitor/108260306" + "uri": "https://api.datadoghq.com/api/v1/monitor/155778018" }, "response": { "body": { - "string": "{\"deleted_monitor_id\":108260306}\n", + "string": "{\"deleted_monitor_id\":155778018}\n", "encoding": null }, "headers": { @@ -94,7 +94,7 @@ "message": "OK" } }, - "recorded_at": "Wed, 18 Jan 2023 18:37:20 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:56 GMT" } ], "recorded_with": "VCR 6.0.0" diff --git a/tests/scenarios/cassettes/v1/monitors/Validate-an-existing-monitor-returns-OK-response.frozen b/tests/scenarios/cassettes/v1/monitors/Validate-an-existing-monitor-returns-OK-response.frozen index dc14445dd..3874e1de2 100644 --- a/tests/scenarios/cassettes/v1/monitors/Validate-an-existing-monitor-returns-OK-response.frozen +++ b/tests/scenarios/cassettes/v1/monitors/Validate-an-existing-monitor-returns-OK-response.frozen @@ -1 +1 @@ -2024-10-09T14:54:55.436Z \ No newline at end of file +2024-10-09T19:10:57.822Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v1/monitors/Validate-an-existing-monitor-returns-OK-response.json b/tests/scenarios/cassettes/v1/monitors/Validate-an-existing-monitor-returns-OK-response.json index a7ab4ec4f..a46e0cbb8 100644 --- a/tests/scenarios/cassettes/v1/monitors/Validate-an-existing-monitor-returns-OK-response.json +++ b/tests/scenarios/cassettes/v1/monitors/Validate-an-existing-monitor-returns-OK-response.json @@ -3,7 +3,7 @@ { "request": { "body": { - "string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Validate_an_existing_monitor_returns_OK_response-1728485695\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2,\"warning\":1},\"timeout_h\":24},\"priority\":3,\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"tags\":[\"test:testvalidateanexistingmonitorreturnsokresponse1728485695\",\"env:ci\"],\"type\":\"log alert\"}", + "string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Validate_an_existing_monitor_returns_OK_response-1728501057\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2,\"warning\":1},\"timeout_h\":24},\"priority\":3,\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"tags\":[\"test:testvalidateanexistingmonitorreturnsokresponse1728501057\",\"env:ci\"],\"type\":\"log alert\"}", "encoding": null }, "headers": { @@ -19,7 +19,7 @@ }, "response": { "body": { - "string": "{\"id\":155758542,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Validate_an_existing_monitor_returns_OK_response-1728485695\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testvalidateanexistingmonitorreturnsokresponse1728485695\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"silenced\":{}},\"multi\":true,\"created_at\":1728485695000,\"created\":\"2024-10-09T14:54:55.594487+00:00\",\"modified\":\"2024-10-09T14:54:55.594487+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"restriction_policy\":null,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":\"Anika Maskara\",\"handle\":\"anika.maskara@datadoghq.com\",\"email\":\"anika.maskara@datadoghq.com\",\"id\":7557262}}\n", + "string": "{\"id\":155778021,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Validate_an_existing_monitor_returns_OK_response-1728501057\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testvalidateanexistingmonitorreturnsokresponse1728501057\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"groupby_simple_monitor\":false,\"silenced\":{}},\"multi\":true,\"created_at\":1728501058000,\"created\":\"2024-10-09T19:10:58.207799+00:00\",\"modified\":\"2024-10-09T19:10:58.207799+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"restriction_policy\":null,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"id\":2320499}}\n", "encoding": null }, "headers": { @@ -32,12 +32,12 @@ "message": "OK" } }, - "recorded_at": "Wed, 09 Oct 2024 14:54:55 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:57 GMT" }, { "request": { "body": { - "string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Validate_an_existing_monitor_returns_OK_response-1728485695\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2,\"warning\":1},\"timeout_h\":24},\"priority\":3,\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"tags\":[\"test:testvalidateanexistingmonitorreturnsokresponse1728485695\",\"env:ci\"],\"type\":\"log alert\"}", + "string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Validate_an_existing_monitor_returns_OK_response-1728501057\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2,\"warning\":1},\"timeout_h\":24},\"priority\":3,\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"tags\":[\"test:testvalidateanexistingmonitorreturnsokresponse1728501057\",\"env:ci\"],\"type\":\"log alert\"}", "encoding": null }, "headers": { @@ -49,7 +49,7 @@ ] }, "method": "post", - "uri": "https://api.datadoghq.com/api/v1/monitor/155758542/validate" + "uri": "https://api.datadoghq.com/api/v1/monitor/155778021/validate" }, "response": { "body": { @@ -66,7 +66,7 @@ "message": "OK" } }, - "recorded_at": "Wed, 09 Oct 2024 14:54:55 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:57 GMT" }, { "request": { @@ -77,11 +77,11 @@ ] }, "method": "delete", - "uri": "https://api.datadoghq.com/api/v1/monitor/155758542" + "uri": "https://api.datadoghq.com/api/v1/monitor/155778021" }, "response": { "body": { - "string": "{\"deleted_monitor_id\":155758542}\n", + "string": "{\"deleted_monitor_id\":155778021}\n", "encoding": null }, "headers": { @@ -94,7 +94,7 @@ "message": "OK" } }, - "recorded_at": "Wed, 09 Oct 2024 14:54:55 GMT" + "recorded_at": "Wed, 09 Oct 2024 19:10:57 GMT" } ], "recorded_with": "VCR 6.0.0" diff --git a/tests/scenarios/features/v1/given.json b/tests/scenarios/features/v1/given.json index 4b7ae56d5..c4f7aa697 100644 --- a/tests/scenarios/features/v1/given.json +++ b/tests/scenarios/features/v1/given.json @@ -166,7 +166,7 @@ "parameters": [ { "name": "body", - "value": "{\n \"name\": \"{{ unique }}\",\n \"type\": \"log alert\",\n \"query\": \"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\n \"message\": \"some message Notify: @hipchat-channel\",\n \"tags\": [\"test:{{ unique_lower_alnum }}\", \"env:ci\"],\n \"priority\": 3,\n \"options\": {\n \"enable_logs_sample\": true,\n \"escalation_message\": \"the situation has escalated\",\n \"evaluation_delay\": 700,\n \"groupby_simple_monitor\": true,\n \"include_tags\": true,\n \"locked\": false,\n \"new_host_delay\": 600,\n \"no_data_timeframe\": null,\n \"notify_audit\": false,\n \"notify_no_data\": false,\n \"on_missing_data\": \"show_and_notify_no_data\",\n \"notification_preset_name\": \"hide_handles\",\n \"renotify_interval\": 60,\n \"require_full_window\": true,\n \"timeout_h\": 24,\n \"thresholds\": { \"critical\": 2, \"warning\": 1 }\n }\n}\n" + "value": "{\n \"name\": \"{{ unique }}\",\n \"type\": \"log alert\",\n \"query\": \"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\n \"message\": \"some message Notify: @hipchat-channel\",\n \"tags\": [\"test:{{ unique_lower_alnum }}\", \"env:ci\"],\n \"priority\": 3,\n \"options\": {\n \"enable_logs_sample\": true,\n \"escalation_message\": \"the situation has escalated\",\n \"evaluation_delay\": 700,\n \"include_tags\": true,\n \"locked\": false,\n \"new_host_delay\": 600,\n \"no_data_timeframe\": null,\n \"notify_audit\": false,\n \"notify_no_data\": false,\n \"on_missing_data\": \"show_and_notify_no_data\",\n \"notification_preset_name\": \"hide_handles\",\n \"renotify_interval\": 60,\n \"require_full_window\": true,\n \"timeout_h\": 24,\n \"thresholds\": { \"critical\": 2, \"warning\": 1 }\n }\n}\n" } ], "step": "there is a valid \"monitor\" in the system", diff --git a/tests/scenarios/features/v2/events.feature b/tests/scenarios/features/v2/events.feature index 9a1c79072..76c854976 100644 --- a/tests/scenarios/features/v2/events.feature +++ b/tests/scenarios/features/v2/events.feature @@ -7,24 +7,26 @@ Feature: Events Background: Given a valid "apiKeyAuth" key in the system - And a valid "appKeyAuth" key in the system And an instance of "Events" API @generated @skip @team:DataDog/event-management Scenario: Get a list of events returns "Bad Request" response - Given new "ListEvents" request + Given a valid "appKeyAuth" key in the system + And new "ListEvents" request When the request is sent Then the response status is 400 Bad Request @skip-validation @team:DataDog/event-management Scenario: Get a list of events returns "OK" response - Given new "ListEvents" request + Given a valid "appKeyAuth" key in the system + And new "ListEvents" request When the request is sent Then the response status is 200 OK @replay-only @skip-validation @team:DataDog/event-management @with-pagination Scenario: Get a list of events returns "OK" response with pagination - Given new "ListEvents" request + Given a valid "appKeyAuth" key in the system + And new "ListEvents" request And request contains "filter[from]" parameter with value "now-15m" And request contains "filter[to]" parameter with value "now" And request contains "page[limit]" parameter with value 2 @@ -34,7 +36,8 @@ Feature: Events @team:DataDog/event-management Scenario: Get a quick list of events returns "OK" response - Given new "ListEvents" request + Given a valid "appKeyAuth" key in the system + And new "ListEvents" request And request contains "filter[query]" parameter with value "datadog-agent" And request contains "filter[from]" parameter with value "2020-09-17T11:48:36+01:00" And request contains "filter[to]" parameter with value "2020-09-17T12:48:36+01:00" @@ -43,16 +46,25 @@ Feature: Events Then the response status is 200 OK And the response "data" has length 0 + @generated @skip @team:DataDog/event-management + Scenario: Post a change event returns "OK" response + Given new "CreateEvent" request + And body with value {"attributes": {"attributes": {"author": {"name": "", "type": "user"}, "change_metadata": {"resource_link": "/feature/fallback_payments_test", "user": {"email": "dd_user_email", "name": "dd_user"}}, "changed_resource": {"name": "fallback_payments_test", "type": "feature_flag"}, "impacted_resources": [{"name": "payments_api", "type": "service"}], "new_value": {"enabled": true, "percentage": "50%", "rule": {"datacenter": "us1.prod"}}, "prev_value": {"enabled": true, "percentage": "10%", "rule": {"datacenter": "us1.prod"}}}, "category": "change", "message": "payment_processed feature flag has been enabled", "tags": ["environment:test"], "title": "payment_processed feature flag updated"}, "type": "event"} + When the request is sent + Then the response status is 200 OK + @team:DataDog/event-management Scenario: Search events returns "Bad Request" response - Given new "SearchEvents" request + Given a valid "appKeyAuth" key in the system + And new "SearchEvents" request And body with value {"filter": {"from": "now-15m", "query": "service:web* AND @http.status_code:[200 TO 299]", "to": "now"}, "options": {"timezone": "GMT"}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "timestamp"} When the request is sent Then the response status is 400 Bad Request @team:DataDog/event-management Scenario: Search events returns "OK" response - Given new "SearchEvents" request + Given a valid "appKeyAuth" key in the system + And new "SearchEvents" request And body with value {"filter": {"query": "datadog-agent", "from": "2020-09-17T11:48:36+01:00", "to": "2020-09-17T12:48:36+01:00"}, "sort": "timestamp", "page": {"limit": 5}} When the request is sent Then the response status is 200 OK @@ -60,7 +72,8 @@ Feature: Events @replay-only @skip-validation @team:DataDog/event-management @with-pagination Scenario: Search events returns "OK" response with pagination - Given new "SearchEvents" request + Given a valid "appKeyAuth" key in the system + And new "SearchEvents" request And body with value {"filter": {"from": "now-15m", "to": "now"}, "options": {"timezone": "GMT"}, "page": {"limit": 2}, "sort": "timestamp"} When the request with pagination is sent Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 62da7c99e..a1592e79b 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -602,6 +602,12 @@ "type": "safe" } }, + "CreateEvent": { + "tag": "Events", + "undo": { + "type": "unsafe" + } + }, "SearchEvents": { "tag": "Events", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 4b82a1063..b5be1cbc0 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -1967,6 +1967,9 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.ListEventsWithPagination".into(), test_v2_list_events_with_pagination, ); + world + .function_mappings + .insert("v2.CreateEvent".into(), test_v2_create_event); world .function_mappings .insert("v2.SearchEvents".into(), test_v2_search_events); @@ -14094,6 +14097,31 @@ fn test_v2_list_events_with_pagination( world.response.code = 200; } +fn test_v2_create_event(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_events + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.create_event_with_http_info(body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + fn test_v2_search_events(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances