Skip to content

Commit

Permalink
Add MSTeams integration metadata info (#2723)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Oct 4, 2024
1 parent ff3a909 commit ffd2e91
Show file tree
Hide file tree
Showing 5 changed files with 374 additions and 6 deletions.
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:19.185228",
"spec_repo_commit": "7a63d530"
"regenerated": "2024-10-04 15:31:50.458429",
"spec_repo_commit": "f28ad048"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-10-04 10:38:19.200021",
"spec_repo_commit": "7a63d530"
"regenerated": "2024-10-04 15:31:50.473143",
"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
36 changes: 34 additions & 2 deletions api/datadogV2/model_incident_integration_metadata_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (

// IncidentIntegrationMetadataMetadata - Incident integration metadata's metadata attribute.
type IncidentIntegrationMetadataMetadata struct {
SlackIntegrationMetadata *SlackIntegrationMetadata
JiraIntegrationMetadata *JiraIntegrationMetadata
SlackIntegrationMetadata *SlackIntegrationMetadata
JiraIntegrationMetadata *JiraIntegrationMetadata
MSTeamsIntegrationMetadata *MSTeamsIntegrationMetadata

// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
UnparsedObject interface{}
Expand All @@ -27,6 +28,11 @@ func JiraIntegrationMetadataAsIncidentIntegrationMetadataMetadata(v *JiraIntegra
return IncidentIntegrationMetadataMetadata{JiraIntegrationMetadata: v}
}

// MSTeamsIntegrationMetadataAsIncidentIntegrationMetadataMetadata is a convenience function that returns MSTeamsIntegrationMetadata wrapped in IncidentIntegrationMetadataMetadata.
func MSTeamsIntegrationMetadataAsIncidentIntegrationMetadataMetadata(v *MSTeamsIntegrationMetadata) IncidentIntegrationMetadataMetadata {
return IncidentIntegrationMetadataMetadata{MSTeamsIntegrationMetadata: v}
}

// UnmarshalJSON turns data into one of the pointers in the struct.
func (obj *IncidentIntegrationMetadataMetadata) UnmarshalJSON(data []byte) error {
var err error
Expand Down Expand Up @@ -65,10 +71,28 @@ func (obj *IncidentIntegrationMetadataMetadata) UnmarshalJSON(data []byte) error
obj.JiraIntegrationMetadata = nil
}

// try to unmarshal data into MSTeamsIntegrationMetadata
err = datadog.Unmarshal(data, &obj.MSTeamsIntegrationMetadata)
if err == nil {
if obj.MSTeamsIntegrationMetadata != nil && obj.MSTeamsIntegrationMetadata.UnparsedObject == nil {
jsonMSTeamsIntegrationMetadata, _ := datadog.Marshal(obj.MSTeamsIntegrationMetadata)
if string(jsonMSTeamsIntegrationMetadata) == "{}" { // empty struct
obj.MSTeamsIntegrationMetadata = nil
} else {
match++
}
} else {
obj.MSTeamsIntegrationMetadata = nil
}
} else {
obj.MSTeamsIntegrationMetadata = nil
}

if match != 1 { // more than 1 match
// reset to nil
obj.SlackIntegrationMetadata = nil
obj.JiraIntegrationMetadata = nil
obj.MSTeamsIntegrationMetadata = nil
return datadog.Unmarshal(data, &obj.UnparsedObject)
}
return nil // exactly one match
Expand All @@ -84,6 +108,10 @@ func (obj IncidentIntegrationMetadataMetadata) MarshalJSON() ([]byte, error) {
return datadog.Marshal(&obj.JiraIntegrationMetadata)
}

if obj.MSTeamsIntegrationMetadata != nil {
return datadog.Marshal(&obj.MSTeamsIntegrationMetadata)
}

if obj.UnparsedObject != nil {
return datadog.Marshal(obj.UnparsedObject)
}
Expand All @@ -100,6 +128,10 @@ func (obj *IncidentIntegrationMetadataMetadata) GetActualInstance() interface{}
return obj.JiraIntegrationMetadata
}

if obj.MSTeamsIntegrationMetadata != nil {
return obj.MSTeamsIntegrationMetadata
}

// all schemas are nil
return nil
}
101 changes: 101 additions & 0 deletions api/datadogV2/model_ms_teams_integration_metadata.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// 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.

package datadogV2

import (
"fmt"

"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
)

// MSTeamsIntegrationMetadata Incident integration metadata for the Microsoft Teams integration.
type MSTeamsIntegrationMetadata struct {
// Array of Microsoft Teams in this integration metadata.
Teams []MSTeamsIntegrationMetadataTeamsItem `json:"teams"`
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
UnparsedObject map[string]interface{} `json:"-"`
AdditionalProperties map[string]interface{} `json:"-"`
}

// NewMSTeamsIntegrationMetadata instantiates a new MSTeamsIntegrationMetadata object.
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed.
func NewMSTeamsIntegrationMetadata(teams []MSTeamsIntegrationMetadataTeamsItem) *MSTeamsIntegrationMetadata {
this := MSTeamsIntegrationMetadata{}
this.Teams = teams
return &this
}

// NewMSTeamsIntegrationMetadataWithDefaults instantiates a new MSTeamsIntegrationMetadata object.
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set.
func NewMSTeamsIntegrationMetadataWithDefaults() *MSTeamsIntegrationMetadata {
this := MSTeamsIntegrationMetadata{}
return &this
}

// GetTeams returns the Teams field value.
func (o *MSTeamsIntegrationMetadata) GetTeams() []MSTeamsIntegrationMetadataTeamsItem {
if o == nil {
var ret []MSTeamsIntegrationMetadataTeamsItem
return ret
}
return o.Teams
}

// GetTeamsOk returns a tuple with the Teams field value
// and a boolean to check if the value has been set.
func (o *MSTeamsIntegrationMetadata) GetTeamsOk() (*[]MSTeamsIntegrationMetadataTeamsItem, bool) {
if o == nil {
return nil, false
}
return &o.Teams, true
}

// SetTeams sets field value.
func (o *MSTeamsIntegrationMetadata) SetTeams(v []MSTeamsIntegrationMetadataTeamsItem) {
o.Teams = v
}

// MarshalJSON serializes the struct using spec logic.
func (o MSTeamsIntegrationMetadata) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.UnparsedObject != nil {
return datadog.Marshal(o.UnparsedObject)
}
toSerialize["teams"] = o.Teams

for key, value := range o.AdditionalProperties {
toSerialize[key] = value
}
return datadog.Marshal(toSerialize)
}

// UnmarshalJSON deserializes the given payload.
func (o *MSTeamsIntegrationMetadata) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
Teams *[]MSTeamsIntegrationMetadataTeamsItem `json:"teams"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
}
if all.Teams == nil {
return fmt.Errorf("required field teams missing")
}
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"teams"})
} else {
return err
}
o.Teams = *all.Teams

if len(additionalProperties) > 0 {
o.AdditionalProperties = additionalProperties
}

return nil
}
Loading

0 comments on commit ffd2e91

Please sign in to comment.