diff --git a/.apigentools-info b/.apigentools-info index a3491d94730..3aaf1f302db 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -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" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 63eb2ce8443..0b749be5074 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -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. @@ -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: diff --git a/api/datadogV2/model_incident_response_included_item.go b/api/datadogV2/model_incident_response_included_item.go index c7d00d179de..d294583793c 100644 --- a/api/datadogV2/model_incident_response_included_item.go +++ b/api/datadogV2/model_incident_response_included_item.go @@ -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. @@ -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 @@ -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) } @@ -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 { @@ -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 { diff --git a/api/datadogV2/model_incident_user_attributes.go b/api/datadogV2/model_incident_user_attributes.go new file mode 100644 index 00000000000..0a402064f36 --- /dev/null +++ b/api/datadogV2/model_incident_user_attributes.go @@ -0,0 +1,253 @@ +// 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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// IncidentUserAttributes Attributes of user object returned by the API. +type IncidentUserAttributes struct { + // Email of the user. + Email *string `json:"email,omitempty"` + // Handle of the user. + Handle *string `json:"handle,omitempty"` + // URL of the user's icon. + Icon *string `json:"icon,omitempty"` + // Name of the user. + Name datadog.NullableString `json:"name,omitempty"` + // UUID of the user. + Uuid *string `json:"uuid,omitempty"` + // 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:"-"` +} + +// NewIncidentUserAttributes instantiates a new IncidentUserAttributes 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 NewIncidentUserAttributes() *IncidentUserAttributes { + this := IncidentUserAttributes{} + return &this +} + +// NewIncidentUserAttributesWithDefaults instantiates a new IncidentUserAttributes 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 NewIncidentUserAttributesWithDefaults() *IncidentUserAttributes { + this := IncidentUserAttributes{} + return &this +} + +// GetEmail returns the Email field value if set, zero value otherwise. +func (o *IncidentUserAttributes) GetEmail() string { + if o == nil || o.Email == nil { + var ret string + return ret + } + return *o.Email +} + +// GetEmailOk returns a tuple with the Email field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentUserAttributes) GetEmailOk() (*string, bool) { + if o == nil || o.Email == nil { + return nil, false + } + return o.Email, true +} + +// HasEmail returns a boolean if a field has been set. +func (o *IncidentUserAttributes) HasEmail() bool { + return o != nil && o.Email != nil +} + +// SetEmail gets a reference to the given string and assigns it to the Email field. +func (o *IncidentUserAttributes) SetEmail(v string) { + o.Email = &v +} + +// GetHandle returns the Handle field value if set, zero value otherwise. +func (o *IncidentUserAttributes) GetHandle() string { + if o == nil || o.Handle == nil { + var ret string + return ret + } + return *o.Handle +} + +// GetHandleOk returns a tuple with the Handle field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentUserAttributes) GetHandleOk() (*string, bool) { + if o == nil || o.Handle == nil { + return nil, false + } + return o.Handle, true +} + +// HasHandle returns a boolean if a field has been set. +func (o *IncidentUserAttributes) HasHandle() bool { + return o != nil && o.Handle != nil +} + +// SetHandle gets a reference to the given string and assigns it to the Handle field. +func (o *IncidentUserAttributes) SetHandle(v string) { + o.Handle = &v +} + +// GetIcon returns the Icon field value if set, zero value otherwise. +func (o *IncidentUserAttributes) GetIcon() string { + if o == nil || o.Icon == nil { + var ret string + return ret + } + return *o.Icon +} + +// GetIconOk returns a tuple with the Icon field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentUserAttributes) GetIconOk() (*string, bool) { + if o == nil || o.Icon == nil { + return nil, false + } + return o.Icon, true +} + +// HasIcon returns a boolean if a field has been set. +func (o *IncidentUserAttributes) HasIcon() bool { + return o != nil && o.Icon != nil +} + +// SetIcon gets a reference to the given string and assigns it to the Icon field. +func (o *IncidentUserAttributes) SetIcon(v string) { + o.Icon = &v +} + +// GetName returns the Name field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *IncidentUserAttributes) GetName() string { + if o == nil || o.Name.Get() == nil { + var ret string + return ret + } + return *o.Name.Get() +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *IncidentUserAttributes) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.Name.Get(), o.Name.IsSet() +} + +// HasName returns a boolean if a field has been set. +func (o *IncidentUserAttributes) HasName() bool { + return o != nil && o.Name.IsSet() +} + +// SetName gets a reference to the given datadog.NullableString and assigns it to the Name field. +func (o *IncidentUserAttributes) SetName(v string) { + o.Name.Set(&v) +} + +// SetNameNil sets the value for Name to be an explicit nil. +func (o *IncidentUserAttributes) SetNameNil() { + o.Name.Set(nil) +} + +// UnsetName ensures that no value is present for Name, not even an explicit nil. +func (o *IncidentUserAttributes) UnsetName() { + o.Name.Unset() +} + +// GetUuid returns the Uuid field value if set, zero value otherwise. +func (o *IncidentUserAttributes) GetUuid() string { + if o == nil || o.Uuid == nil { + var ret string + return ret + } + return *o.Uuid +} + +// GetUuidOk returns a tuple with the Uuid field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentUserAttributes) GetUuidOk() (*string, bool) { + if o == nil || o.Uuid == nil { + return nil, false + } + return o.Uuid, true +} + +// HasUuid returns a boolean if a field has been set. +func (o *IncidentUserAttributes) HasUuid() bool { + return o != nil && o.Uuid != nil +} + +// SetUuid gets a reference to the given string and assigns it to the Uuid field. +func (o *IncidentUserAttributes) SetUuid(v string) { + o.Uuid = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentUserAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Email != nil { + toSerialize["email"] = o.Email + } + if o.Handle != nil { + toSerialize["handle"] = o.Handle + } + if o.Icon != nil { + toSerialize["icon"] = o.Icon + } + if o.Name.IsSet() { + toSerialize["name"] = o.Name.Get() + } + if o.Uuid != nil { + toSerialize["uuid"] = o.Uuid + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentUserAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Email *string `json:"email,omitempty"` + Handle *string `json:"handle,omitempty"` + Icon *string `json:"icon,omitempty"` + Name datadog.NullableString `json:"name,omitempty"` + Uuid *string `json:"uuid,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"email", "handle", "icon", "name", "uuid"}) + } else { + return err + } + o.Email = all.Email + o.Handle = all.Handle + o.Icon = all.Icon + o.Name = all.Name + o.Uuid = all.Uuid + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_incident_user_data.go b/api/datadogV2/model_incident_user_data.go new file mode 100644 index 00000000000..46584130c73 --- /dev/null +++ b/api/datadogV2/model_incident_user_data.go @@ -0,0 +1,189 @@ +// 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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// IncidentUserData User object returned by the API. +type IncidentUserData struct { + // Attributes of user object returned by the API. + Attributes *IncidentUserAttributes `json:"attributes,omitempty"` + // ID of the user. + Id *string `json:"id,omitempty"` + // Users resource type. + Type *UsersType `json:"type,omitempty"` + // 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:"-"` +} + +// NewIncidentUserData instantiates a new IncidentUserData 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 NewIncidentUserData() *IncidentUserData { + this := IncidentUserData{} + var typeVar UsersType = USERSTYPE_USERS + this.Type = &typeVar + return &this +} + +// NewIncidentUserDataWithDefaults instantiates a new IncidentUserData 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 NewIncidentUserDataWithDefaults() *IncidentUserData { + this := IncidentUserData{} + var typeVar UsersType = USERSTYPE_USERS + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *IncidentUserData) GetAttributes() IncidentUserAttributes { + if o == nil || o.Attributes == nil { + var ret IncidentUserAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentUserData) GetAttributesOk() (*IncidentUserAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *IncidentUserData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given IncidentUserAttributes and assigns it to the Attributes field. +func (o *IncidentUserData) SetAttributes(v IncidentUserAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *IncidentUserData) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentUserData) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *IncidentUserData) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *IncidentUserData) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *IncidentUserData) GetType() UsersType { + if o == nil || o.Type == nil { + var ret UsersType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentUserData) GetTypeOk() (*UsersType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *IncidentUserData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given UsersType and assigns it to the Type field. +func (o *IncidentUserData) SetType(v UsersType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentUserData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentUserData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *IncidentUserAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Type *UsersType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + o.Id = all.Id + if all.Type != nil && !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +}