55package datadogV2
66
77import (
8- "fmt"
9-
108 "github.com/DataDog/datadog-api-client-go/v2/api/datadog"
119)
1210
13- // IncidentAttachmentUpdateResponse The response object containing the created or updated incident attachments.
14- type IncidentAttachmentUpdateResponse struct {
15- // An array of incident attachments. Only the attachments that were created or updated by the request are
16- // returned.
17- Data []IncidentAttachmentData `json:"data"`
18- // Included related resources that the user requested.
19- Included []IncidentAttachmentsResponseIncludedItem `json:"included,omitempty"`
11+ // Attachment
12+ type Attachment struct {
13+ //
14+ Data * AttachmentData `json:"data,omitempty"`
15+ //
16+ Included []AttachmentIncluded `json:"included,omitempty"`
2017 // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
2118 UnparsedObject map [string ]interface {} `json:"-"`
2219 AdditionalProperties map [string ]interface {} `json:"-"`
2320}
2421
25- // NewIncidentAttachmentUpdateResponse instantiates a new IncidentAttachmentUpdateResponse object.
22+ // NewAttachment instantiates a new Attachment object.
2623// This constructor will assign default values to properties that have it defined,
2724// and makes sure properties required by API are set, but the set of arguments
2825// will change when the set of required properties is changed.
29- func NewIncidentAttachmentUpdateResponse (data []IncidentAttachmentData ) * IncidentAttachmentUpdateResponse {
30- this := IncidentAttachmentUpdateResponse {}
31- this .Data = data
26+ func NewAttachment () * Attachment {
27+ this := Attachment {}
3228 return & this
3329}
3430
35- // NewIncidentAttachmentUpdateResponseWithDefaults instantiates a new IncidentAttachmentUpdateResponse object.
31+ // NewAttachmentWithDefaults instantiates a new Attachment object.
3632// This constructor will only assign default values to properties that have it defined,
3733// but it doesn't guarantee that properties required by API are set.
38- func NewIncidentAttachmentUpdateResponseWithDefaults () * IncidentAttachmentUpdateResponse {
39- this := IncidentAttachmentUpdateResponse {}
34+ func NewAttachmentWithDefaults () * Attachment {
35+ this := Attachment {}
4036 return & this
4137}
4238
43- // GetData returns the Data field value.
44- func (o * IncidentAttachmentUpdateResponse ) GetData () [] IncidentAttachmentData {
45- if o == nil {
46- var ret [] IncidentAttachmentData
39+ // GetData returns the Data field value if set, zero value otherwise .
40+ func (o * Attachment ) GetData () AttachmentData {
41+ if o == nil || o . Data == nil {
42+ var ret AttachmentData
4743 return ret
4844 }
49- return o .Data
45+ return * o .Data
5046}
5147
52- // GetDataOk returns a tuple with the Data field value
48+ // GetDataOk returns a tuple with the Data field value if set, nil otherwise
5349// and a boolean to check if the value has been set.
54- func (o * IncidentAttachmentUpdateResponse ) GetDataOk () (* [] IncidentAttachmentData , bool ) {
55- if o == nil {
50+ func (o * Attachment ) GetDataOk () (* AttachmentData , bool ) {
51+ if o == nil || o . Data == nil {
5652 return nil , false
5753 }
58- return & o .Data , true
54+ return o .Data , true
55+ }
56+
57+ // HasData returns a boolean if a field has been set.
58+ func (o * Attachment ) HasData () bool {
59+ return o != nil && o .Data != nil
5960}
6061
61- // SetData sets field value .
62- func (o * IncidentAttachmentUpdateResponse ) SetData (v [] IncidentAttachmentData ) {
63- o .Data = v
62+ // SetData gets a reference to the given AttachmentData and assigns it to the Data field .
63+ func (o * Attachment ) SetData (v AttachmentData ) {
64+ o .Data = & v
6465}
6566
6667// GetIncluded returns the Included field value if set, zero value otherwise.
67- func (o * IncidentAttachmentUpdateResponse ) GetIncluded () []IncidentAttachmentsResponseIncludedItem {
68+ func (o * Attachment ) GetIncluded () []AttachmentIncluded {
6869 if o == nil || o .Included == nil {
69- var ret []IncidentAttachmentsResponseIncludedItem
70+ var ret []AttachmentIncluded
7071 return ret
7172 }
7273 return o .Included
7374}
7475
7576// GetIncludedOk returns a tuple with the Included field value if set, nil otherwise
7677// and a boolean to check if the value has been set.
77- func (o * IncidentAttachmentUpdateResponse ) GetIncludedOk () (* []IncidentAttachmentsResponseIncludedItem , bool ) {
78+ func (o * Attachment ) GetIncludedOk () (* []AttachmentIncluded , bool ) {
7879 if o == nil || o .Included == nil {
7980 return nil , false
8081 }
8182 return & o .Included , true
8283}
8384
8485// HasIncluded returns a boolean if a field has been set.
85- func (o * IncidentAttachmentUpdateResponse ) HasIncluded () bool {
86+ func (o * Attachment ) HasIncluded () bool {
8687 return o != nil && o .Included != nil
8788}
8889
89- // SetIncluded gets a reference to the given []IncidentAttachmentsResponseIncludedItem and assigns it to the Included field.
90- func (o * IncidentAttachmentUpdateResponse ) SetIncluded (v []IncidentAttachmentsResponseIncludedItem ) {
90+ // SetIncluded gets a reference to the given []AttachmentIncluded and assigns it to the Included field.
91+ func (o * Attachment ) SetIncluded (v []AttachmentIncluded ) {
9192 o .Included = v
9293}
9394
9495// MarshalJSON serializes the struct using spec logic.
95- func (o IncidentAttachmentUpdateResponse ) MarshalJSON () ([]byte , error ) {
96+ func (o Attachment ) MarshalJSON () ([]byte , error ) {
9697 toSerialize := map [string ]interface {}{}
9798 if o .UnparsedObject != nil {
9899 return datadog .Marshal (o .UnparsedObject )
99100 }
100- toSerialize ["data" ] = o .Data
101+ if o .Data != nil {
102+ toSerialize ["data" ] = o .Data
103+ }
101104 if o .Included != nil {
102105 toSerialize ["included" ] = o .Included
103106 }
@@ -109,29 +112,35 @@ func (o IncidentAttachmentUpdateResponse) MarshalJSON() ([]byte, error) {
109112}
110113
111114// UnmarshalJSON deserializes the given payload.
112- func (o * IncidentAttachmentUpdateResponse ) UnmarshalJSON (bytes []byte ) (err error ) {
115+ func (o * Attachment ) UnmarshalJSON (bytes []byte ) (err error ) {
113116 all := struct {
114- Data * [] IncidentAttachmentData `json:"data"`
115- Included []IncidentAttachmentsResponseIncludedItem `json:"included,omitempty"`
117+ Data * AttachmentData `json:"data,omitempty "`
118+ Included []AttachmentIncluded `json:"included,omitempty"`
116119 }{}
117120 if err = datadog .Unmarshal (bytes , & all ); err != nil {
118121 return datadog .Unmarshal (bytes , & o .UnparsedObject )
119122 }
120- if all .Data == nil {
121- return fmt .Errorf ("required field data missing" )
122- }
123123 additionalProperties := make (map [string ]interface {})
124124 if err = datadog .Unmarshal (bytes , & additionalProperties ); err == nil {
125125 datadog .DeleteKeys (additionalProperties , & []string {"data" , "included" })
126126 } else {
127127 return err
128128 }
129- o .Data = * all .Data
129+
130+ hasInvalidField := false
131+ if all .Data != nil && all .Data .UnparsedObject != nil && o .UnparsedObject == nil {
132+ hasInvalidField = true
133+ }
134+ o .Data = all .Data
130135 o .Included = all .Included
131136
132137 if len (additionalProperties ) > 0 {
133138 o .AdditionalProperties = additionalProperties
134139 }
135140
141+ if hasInvalidField {
142+ return datadog .Unmarshal (bytes , & o .UnparsedObject )
143+ }
144+
136145 return nil
137146}
0 commit comments