Skip to content

Add MSTeams integration metadata info #326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-10-04 10:38:16.608195",
"spec_repo_commit": "7a63d530"
"regenerated": "2024-10-04 15:31:58.294860",
"spec_repo_commit": "f28ad048"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-10-04 10:38:16.622752",
"spec_repo_commit": "7a63d530"
"regenerated": "2024-10-04 15:31:58.309733",
"spec_repo_commit": "f28ad048"
}
}
}
38 changes: 38 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10640,6 +10640,7 @@ components:
oneOf:
- $ref: '#/components/schemas/SlackIntegrationMetadata'
- $ref: '#/components/schemas/JiraIntegrationMetadata'
- $ref: '#/components/schemas/MSTeamsIntegrationMetadata'
IncidentIntegrationMetadataPatchData:
description: Incident integration metadata data for a patch request.
properties:
Expand Down Expand Up @@ -13634,6 +13635,43 @@ components:
from the other indexes
type: string
type: object
MSTeamsIntegrationMetadata:
description: Incident integration metadata for the Microsoft Teams integration.
properties:
teams:
description: Array of Microsoft Teams in this integration metadata.
example: []
items:
$ref: '#/components/schemas/MSTeamsIntegrationMetadataTeamsItem'
type: array
required:
- teams
type: object
MSTeamsIntegrationMetadataTeamsItem:
description: Item in the Microsoft Teams integration metadata teams array.
properties:
ms_channel_id:
description: Microsoft Teams channel ID.
example: 19:abc00abcdef00a0abcdef0abcdef0a@thread.tacv2
type: string
ms_channel_name:
description: Microsoft Teams channel name.
example: incident-0001-example
type: string
ms_tenant_id:
description: Microsoft Teams tenant ID.
example: 00000000-abcd-0005-0000-000000000000
type: string
redirect_url:
description: URL redirecting to the Microsoft Teams channel.
example: https://teams.microsoft.com/l/channel/19%3Aabc00abcdef00a0abcdef0abcdef0a%40thread.tacv2/conversations?groupId=12345678-abcd-dcba-abcd-1234567890ab&tenantId=00000000-abcd-0005-0000-000000000000
type: string
required:
- ms_tenant_id
- ms_channel_id
- ms_channel_name
- redirect_url
type: object
Metric:
description: Object for a single metric tag configuration.
example:
Expand Down
4 changes: 4 additions & 0 deletions src/datadogV2/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,10 @@ pub mod model_jira_integration_metadata;
pub use self::model_jira_integration_metadata::JiraIntegrationMetadata;
pub mod model_jira_integration_metadata_issues_item;
pub use self::model_jira_integration_metadata_issues_item::JiraIntegrationMetadataIssuesItem;
pub mod model_ms_teams_integration_metadata;
pub use self::model_ms_teams_integration_metadata::MSTeamsIntegrationMetadata;
pub mod model_ms_teams_integration_metadata_teams_item;
pub use self::model_ms_teams_integration_metadata_teams_item::MSTeamsIntegrationMetadataTeamsItem;
pub mod model_incident_integration_metadata_metadata;
pub use self::model_incident_integration_metadata_metadata::IncidentIntegrationMetadataMetadata;
pub mod model_incident_integration_relationships;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use serde::{Deserialize, Deserializer, Serialize};
pub enum IncidentIntegrationMetadataMetadata {
SlackIntegrationMetadata(Box<crate::datadogV2::model::SlackIntegrationMetadata>),
JiraIntegrationMetadata(Box<crate::datadogV2::model::JiraIntegrationMetadata>),
MSTeamsIntegrationMetadata(Box<crate::datadogV2::model::MSTeamsIntegrationMetadata>),
UnparsedObject(crate::datadog::UnparsedObject),
}

Expand All @@ -35,6 +36,14 @@ impl<'de> Deserialize<'de> for IncidentIntegrationMetadataMetadata {
return Ok(IncidentIntegrationMetadataMetadata::JiraIntegrationMetadata(_v));
}
}
if let Ok(_v) = serde_json::from_value::<
Box<crate::datadogV2::model::MSTeamsIntegrationMetadata>,
>(value.clone())
{
if !_v._unparsed {
return Ok(IncidentIntegrationMetadataMetadata::MSTeamsIntegrationMetadata(_v));
}
}

return Ok(IncidentIntegrationMetadataMetadata::UnparsedObject(
crate::datadog::UnparsedObject { value },
Expand Down
96 changes: 96 additions & 0 deletions src/datadogV2/model/model_ms_teams_integration_metadata.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// 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};

/// Incident integration metadata for the Microsoft Teams integration.
#[non_exhaustive]
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct MSTeamsIntegrationMetadata {
/// Array of Microsoft Teams in this integration metadata.
#[serde(rename = "teams")]
pub teams: Vec<crate::datadogV2::model::MSTeamsIntegrationMetadataTeamsItem>,
#[serde(flatten)]
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
#[serde(skip)]
#[serde(default)]
pub(crate) _unparsed: bool,
}

impl MSTeamsIntegrationMetadata {
pub fn new(
teams: Vec<crate::datadogV2::model::MSTeamsIntegrationMetadataTeamsItem>,
) -> MSTeamsIntegrationMetadata {
MSTeamsIntegrationMetadata {
teams,
additional_properties: std::collections::BTreeMap::new(),
_unparsed: false,
}
}

pub fn additional_properties(
mut self,
value: std::collections::BTreeMap<String, serde_json::Value>,
) -> Self {
self.additional_properties = value;
self
}
}

impl<'de> Deserialize<'de> for MSTeamsIntegrationMetadata {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct MSTeamsIntegrationMetadataVisitor;
impl<'a> Visitor<'a> for MSTeamsIntegrationMetadataVisitor {
type Value = MSTeamsIntegrationMetadata;

fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.write_str("a mapping")
}

fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
where
M: MapAccess<'a>,
{
let mut teams: Option<
Vec<crate::datadogV2::model::MSTeamsIntegrationMetadataTeamsItem>,
> = 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::<String, serde_json::Value>()? {
match k.as_str() {
"teams" => {
teams = 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 teams = teams.ok_or_else(|| M::Error::missing_field("teams"))?;

let content = MSTeamsIntegrationMetadata {
teams,
additional_properties,
_unparsed,
};

Ok(content)
}
}

deserializer.deserialize_any(MSTeamsIntegrationMetadataVisitor)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
// 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};

/// Item in the Microsoft Teams integration metadata teams array.
#[non_exhaustive]
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct MSTeamsIntegrationMetadataTeamsItem {
/// Microsoft Teams channel ID.
#[serde(rename = "ms_channel_id")]
pub ms_channel_id: String,
/// Microsoft Teams channel name.
#[serde(rename = "ms_channel_name")]
pub ms_channel_name: String,
/// Microsoft Teams tenant ID.
#[serde(rename = "ms_tenant_id")]
pub ms_tenant_id: String,
/// URL redirecting to the Microsoft Teams channel.
#[serde(rename = "redirect_url")]
pub redirect_url: String,
#[serde(flatten)]
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
#[serde(skip)]
#[serde(default)]
pub(crate) _unparsed: bool,
}

impl MSTeamsIntegrationMetadataTeamsItem {
pub fn new(
ms_channel_id: String,
ms_channel_name: String,
ms_tenant_id: String,
redirect_url: String,
) -> MSTeamsIntegrationMetadataTeamsItem {
MSTeamsIntegrationMetadataTeamsItem {
ms_channel_id,
ms_channel_name,
ms_tenant_id,
redirect_url,
additional_properties: std::collections::BTreeMap::new(),
_unparsed: false,
}
}

pub fn additional_properties(
mut self,
value: std::collections::BTreeMap<String, serde_json::Value>,
) -> Self {
self.additional_properties = value;
self
}
}

impl<'de> Deserialize<'de> for MSTeamsIntegrationMetadataTeamsItem {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct MSTeamsIntegrationMetadataTeamsItemVisitor;
impl<'a> Visitor<'a> for MSTeamsIntegrationMetadataTeamsItemVisitor {
type Value = MSTeamsIntegrationMetadataTeamsItem;

fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.write_str("a mapping")
}

fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
where
M: MapAccess<'a>,
{
let mut ms_channel_id: Option<String> = None;
let mut ms_channel_name: Option<String> = None;
let mut ms_tenant_id: Option<String> = None;
let mut redirect_url: Option<String> = 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::<String, serde_json::Value>()? {
match k.as_str() {
"ms_channel_id" => {
ms_channel_id =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"ms_channel_name" => {
ms_channel_name =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"ms_tenant_id" => {
ms_tenant_id =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"redirect_url" => {
redirect_url =
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 ms_channel_id =
ms_channel_id.ok_or_else(|| M::Error::missing_field("ms_channel_id"))?;
let ms_channel_name =
ms_channel_name.ok_or_else(|| M::Error::missing_field("ms_channel_name"))?;
let ms_tenant_id =
ms_tenant_id.ok_or_else(|| M::Error::missing_field("ms_tenant_id"))?;
let redirect_url =
redirect_url.ok_or_else(|| M::Error::missing_field("redirect_url"))?;

let content = MSTeamsIntegrationMetadataTeamsItem {
ms_channel_id,
ms_channel_name,
ms_tenant_id,
redirect_url,
additional_properties,
_unparsed,
};

Ok(content)
}
}

deserializer.deserialize_any(MSTeamsIntegrationMetadataTeamsItemVisitor)
}
}
Loading