Skip to content
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

Add a new contact type in service catalog api for schema v2 and v2.1 #1930

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.4",
"regenerated": "2023-04-04 17:50:47.601802",
"spec_repo_commit": "9a7b22d0"
"regenerated": "2023-04-05 14:45:44.153800",
"spec_repo_commit": "627d5fdd"
},
"v2": {
"apigentools_version": "1.6.4",
"regenerated": "2023-04-04 17:50:47.618329",
"spec_repo_commit": "9a7b22d0"
"regenerated": "2023-04-05 14:45:44.171367",
"spec_repo_commit": "627d5fdd"
}
}
}
52 changes: 52 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12425,6 +12425,7 @@ components:
oneOf:
- $ref: '#/components/schemas/ServiceDefinitionV2Email'
- $ref: '#/components/schemas/ServiceDefinitionV2Slack'
- $ref: '#/components/schemas/ServiceDefinitionV2MSTeams'
ServiceDefinitionV2Doc:
description: Service documents.
properties:
Expand Down Expand Up @@ -12511,6 +12512,7 @@ components:
oneOf:
- $ref: '#/components/schemas/ServiceDefinitionV2Dot1Email'
- $ref: '#/components/schemas/ServiceDefinitionV2Dot1Slack'
- $ref: '#/components/schemas/ServiceDefinitionV2Dot1MSTeams'
ServiceDefinitionV2Dot1Email:
description: Service owner's email.
properties:
Expand Down Expand Up @@ -12583,6 +12585,31 @@ components:
- RUNBOOK
- DASHBOARD
- OTHER
ServiceDefinitionV2Dot1MSTeams:
description: Service owner's Microsoft Teams.
properties:
contact:
description: Contact value.
example: https://teams.microsoft.com/myteam
type: string
name:
description: Contact Microsoft Teams.
example: My team channel
type: string
type:
$ref: '#/components/schemas/ServiceDefinitionV2Dot1MSTeamsType'
required:
- type
- contact
type: object
ServiceDefinitionV2Dot1MSTeamsType:
description: Contact type.
enum:
- microsoft-teams
example: microsoft-teams
type: string
x-enum-varnames:
- MICROSOFT_TEAMS
ServiceDefinitionV2Dot1Opsgenie:
description: Opsgenie integration for the service.
properties:
Expand Down Expand Up @@ -12723,6 +12750,31 @@ components:
- ONCALL
- CODE
- LINK
ServiceDefinitionV2MSTeams:
description: Service owner's Microsoft Teams.
properties:
contact:
description: Contact value.
example: https://teams.microsoft.com/myteam
type: string
name:
description: Contact Microsoft Teams.
example: My team channel
type: string
type:
$ref: '#/components/schemas/ServiceDefinitionV2MSTeamsType'
required:
- type
- contact
type: object
ServiceDefinitionV2MSTeamsType:
description: Contact type.
enum:
- microsoft-teams
example: microsoft-teams
type: string
x-enum-varnames:
- MICROSOFT_TEAMS
ServiceDefinitionV2Opsgenie:
description: Opsgenie integration for the service.
properties:
Expand Down
36 changes: 34 additions & 2 deletions api/datadogV2/model_service_definition_v2_contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (

// ServiceDefinitionV2Contact - Service owner's contacts information.
type ServiceDefinitionV2Contact struct {
ServiceDefinitionV2Email *ServiceDefinitionV2Email
ServiceDefinitionV2Slack *ServiceDefinitionV2Slack
ServiceDefinitionV2Email *ServiceDefinitionV2Email
ServiceDefinitionV2Slack *ServiceDefinitionV2Slack
ServiceDefinitionV2MSTeams *ServiceDefinitionV2MSTeams

// 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 ServiceDefinitionV2SlackAsServiceDefinitionV2Contact(v *ServiceDefinitionV2
return ServiceDefinitionV2Contact{ServiceDefinitionV2Slack: v}
}

// ServiceDefinitionV2MSTeamsAsServiceDefinitionV2Contact is a convenience function that returns ServiceDefinitionV2MSTeams wrapped in ServiceDefinitionV2Contact.
func ServiceDefinitionV2MSTeamsAsServiceDefinitionV2Contact(v *ServiceDefinitionV2MSTeams) ServiceDefinitionV2Contact {
return ServiceDefinitionV2Contact{ServiceDefinitionV2MSTeams: v}
}

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

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

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

if obj.ServiceDefinitionV2MSTeams != nil {
return json.Marshal(&obj.ServiceDefinitionV2MSTeams)
}

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

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

// all schemas are nil
return nil
}
Expand Down
36 changes: 34 additions & 2 deletions api/datadogV2/model_service_definition_v2_dot1_contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (

// ServiceDefinitionV2Dot1Contact - Service owner's contacts information.
type ServiceDefinitionV2Dot1Contact struct {
ServiceDefinitionV2Dot1Email *ServiceDefinitionV2Dot1Email
ServiceDefinitionV2Dot1Slack *ServiceDefinitionV2Dot1Slack
ServiceDefinitionV2Dot1Email *ServiceDefinitionV2Dot1Email
ServiceDefinitionV2Dot1Slack *ServiceDefinitionV2Dot1Slack
ServiceDefinitionV2Dot1MSTeams *ServiceDefinitionV2Dot1MSTeams

// 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 ServiceDefinitionV2Dot1SlackAsServiceDefinitionV2Dot1Contact(v *ServiceDefi
return ServiceDefinitionV2Dot1Contact{ServiceDefinitionV2Dot1Slack: v}
}

// ServiceDefinitionV2Dot1MSTeamsAsServiceDefinitionV2Dot1Contact is a convenience function that returns ServiceDefinitionV2Dot1MSTeams wrapped in ServiceDefinitionV2Dot1Contact.
func ServiceDefinitionV2Dot1MSTeamsAsServiceDefinitionV2Dot1Contact(v *ServiceDefinitionV2Dot1MSTeams) ServiceDefinitionV2Dot1Contact {
return ServiceDefinitionV2Dot1Contact{ServiceDefinitionV2Dot1MSTeams: v}
}

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

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

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

if obj.ServiceDefinitionV2Dot1MSTeams != nil {
return json.Marshal(&obj.ServiceDefinitionV2Dot1MSTeams)
}

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

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

// all schemas are nil
return nil
}
Expand Down
Loading