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

Remove user fields that are unsupported by the Incidents API #2721

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-02 20:43:00.348465",
"spec_repo_commit": "76b7b19d"
"regenerated": "2024-10-03 13:53:52.224483",
"spec_repo_commit": "2c46d95c"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-10-02 20:43:00.363246",
"spec_repo_commit": "76b7b19d"
"regenerated": "2024-10-03 13:53:52.241054",
"spec_repo_commit": "2c46d95c"
}
}
}
33 changes: 32 additions & 1 deletion .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10930,7 +10930,7 @@ components:
IncidentResponseIncludedItem:
description: An object related to an incident that is included in the response.
oneOf:
- $ref: '#/components/schemas/User'
- $ref: '#/components/schemas/IncidentUserData'
- $ref: '#/components/schemas/IncidentAttachmentData'
IncidentResponseMeta:
description: The metadata object containing pagination metadata.
Expand Down Expand Up @@ -11869,6 +11869,37 @@ components:
required:
- data
type: object
IncidentUserAttributes:
description: Attributes of user object returned by the API.
properties:
email:
description: Email of the user.
type: string
handle:
description: Handle of the user.
type: string
icon:
description: URL of the user's icon.
type: string
name:
description: Name of the user.
nullable: true
type: string
uuid:
description: UUID of the user.
type: string
type: object
IncidentUserData:
description: User object returned by the API.
properties:
attributes:
$ref: '#/components/schemas/IncidentUserAttributes'
id:
description: ID of the user.
type: string
type:
$ref: '#/components/schemas/UsersType'
type: object
IncidentUserDefinedFieldType:
description: The incident user defined fields type.
enum:
Expand Down
34 changes: 17 additions & 17 deletions api/datadogV2/model_incident_response_included_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import (

// IncidentResponseIncludedItem - An object related to an incident that is included in the response.
type IncidentResponseIncludedItem struct {
User *User
IncidentUserData *IncidentUserData
IncidentAttachmentData *IncidentAttachmentData

// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
UnparsedObject interface{}
}

// UserAsIncidentResponseIncludedItem is a convenience function that returns User wrapped in IncidentResponseIncludedItem.
func UserAsIncidentResponseIncludedItem(v *User) IncidentResponseIncludedItem {
return IncidentResponseIncludedItem{User: v}
// IncidentUserDataAsIncidentResponseIncludedItem is a convenience function that returns IncidentUserData wrapped in IncidentResponseIncludedItem.
func IncidentUserDataAsIncidentResponseIncludedItem(v *IncidentUserData) IncidentResponseIncludedItem {
return IncidentResponseIncludedItem{IncidentUserData: v}
}

// IncidentAttachmentDataAsIncidentResponseIncludedItem is a convenience function that returns IncidentAttachmentData wrapped in IncidentResponseIncludedItem.
Expand All @@ -31,21 +31,21 @@ func IncidentAttachmentDataAsIncidentResponseIncludedItem(v *IncidentAttachmentD
func (obj *IncidentResponseIncludedItem) UnmarshalJSON(data []byte) error {
var err error
match := 0
// try to unmarshal data into User
err = datadog.Unmarshal(data, &obj.User)
// try to unmarshal data into IncidentUserData
err = datadog.Unmarshal(data, &obj.IncidentUserData)
if err == nil {
if obj.User != nil && obj.User.UnparsedObject == nil {
jsonUser, _ := datadog.Marshal(obj.User)
if string(jsonUser) == "{}" && string(data) != "{}" { // empty struct
obj.User = nil
if obj.IncidentUserData != nil && obj.IncidentUserData.UnparsedObject == nil {
jsonIncidentUserData, _ := datadog.Marshal(obj.IncidentUserData)
if string(jsonIncidentUserData) == "{}" && string(data) != "{}" { // empty struct
obj.IncidentUserData = nil
} else {
match++
}
} else {
obj.User = nil
obj.IncidentUserData = nil
}
} else {
obj.User = nil
obj.IncidentUserData = nil
}

// try to unmarshal data into IncidentAttachmentData
Expand All @@ -67,7 +67,7 @@ func (obj *IncidentResponseIncludedItem) UnmarshalJSON(data []byte) error {

if match != 1 { // more than 1 match
// reset to nil
obj.User = nil
obj.IncidentUserData = nil
obj.IncidentAttachmentData = nil
return datadog.Unmarshal(data, &obj.UnparsedObject)
}
Expand All @@ -76,8 +76,8 @@ func (obj *IncidentResponseIncludedItem) UnmarshalJSON(data []byte) error {

// MarshalJSON turns data from the first non-nil pointers in the struct to JSON.
func (obj IncidentResponseIncludedItem) MarshalJSON() ([]byte, error) {
if obj.User != nil {
return datadog.Marshal(&obj.User)
if obj.IncidentUserData != nil {
return datadog.Marshal(&obj.IncidentUserData)
}

if obj.IncidentAttachmentData != nil {
Expand All @@ -92,8 +92,8 @@ func (obj IncidentResponseIncludedItem) MarshalJSON() ([]byte, error) {

// GetActualInstance returns the actual instance.
func (obj *IncidentResponseIncludedItem) GetActualInstance() interface{} {
if obj.User != nil {
return obj.User
if obj.IncidentUserData != nil {
return obj.IncidentUserData
}

if obj.IncidentAttachmentData != nil {
Expand Down
Loading
Loading