|
| 1 | +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. |
| 2 | +// This product includes software developed at Datadog (https://www.datadoghq.com/). |
| 3 | +// Copyright 2019-Present Datadog, Inc. |
| 4 | + |
| 5 | +package datadogV2 |
| 6 | + |
| 7 | +import ( |
| 8 | + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" |
| 9 | +) |
| 10 | + |
| 11 | +// WebhooksAuthMethodRelationships Relationships of a webhooks auth method to its protocol-specific resource. |
| 12 | +type WebhooksAuthMethodRelationships struct { |
| 13 | + // Relationship pointing to the OAuth2 client credentials resource for this auth method. |
| 14 | + Oauth2ClientCredentials *WebhooksOAuth2ClientCredentialsRelationship `json:"oauth2-client-credentials,omitempty"` |
| 15 | + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct |
| 16 | + UnparsedObject map[string]interface{} `json:"-"` |
| 17 | + AdditionalProperties map[string]interface{} `json:"-"` |
| 18 | +} |
| 19 | + |
| 20 | +// NewWebhooksAuthMethodRelationships instantiates a new WebhooksAuthMethodRelationships object. |
| 21 | +// This constructor will assign default values to properties that have it defined, |
| 22 | +// and makes sure properties required by API are set, but the set of arguments |
| 23 | +// will change when the set of required properties is changed. |
| 24 | +func NewWebhooksAuthMethodRelationships() *WebhooksAuthMethodRelationships { |
| 25 | + this := WebhooksAuthMethodRelationships{} |
| 26 | + return &this |
| 27 | +} |
| 28 | + |
| 29 | +// NewWebhooksAuthMethodRelationshipsWithDefaults instantiates a new WebhooksAuthMethodRelationships object. |
| 30 | +// This constructor will only assign default values to properties that have it defined, |
| 31 | +// but it doesn't guarantee that properties required by API are set. |
| 32 | +func NewWebhooksAuthMethodRelationshipsWithDefaults() *WebhooksAuthMethodRelationships { |
| 33 | + this := WebhooksAuthMethodRelationships{} |
| 34 | + return &this |
| 35 | +} |
| 36 | + |
| 37 | +// GetOauth2ClientCredentials returns the Oauth2ClientCredentials field value if set, zero value otherwise. |
| 38 | +func (o *WebhooksAuthMethodRelationships) GetOauth2ClientCredentials() WebhooksOAuth2ClientCredentialsRelationship { |
| 39 | + if o == nil || o.Oauth2ClientCredentials == nil { |
| 40 | + var ret WebhooksOAuth2ClientCredentialsRelationship |
| 41 | + return ret |
| 42 | + } |
| 43 | + return *o.Oauth2ClientCredentials |
| 44 | +} |
| 45 | + |
| 46 | +// GetOauth2ClientCredentialsOk returns a tuple with the Oauth2ClientCredentials field value if set, nil otherwise |
| 47 | +// and a boolean to check if the value has been set. |
| 48 | +func (o *WebhooksAuthMethodRelationships) GetOauth2ClientCredentialsOk() (*WebhooksOAuth2ClientCredentialsRelationship, bool) { |
| 49 | + if o == nil || o.Oauth2ClientCredentials == nil { |
| 50 | + return nil, false |
| 51 | + } |
| 52 | + return o.Oauth2ClientCredentials, true |
| 53 | +} |
| 54 | + |
| 55 | +// HasOauth2ClientCredentials returns a boolean if a field has been set. |
| 56 | +func (o *WebhooksAuthMethodRelationships) HasOauth2ClientCredentials() bool { |
| 57 | + return o != nil && o.Oauth2ClientCredentials != nil |
| 58 | +} |
| 59 | + |
| 60 | +// SetOauth2ClientCredentials gets a reference to the given WebhooksOAuth2ClientCredentialsRelationship and assigns it to the Oauth2ClientCredentials field. |
| 61 | +func (o *WebhooksAuthMethodRelationships) SetOauth2ClientCredentials(v WebhooksOAuth2ClientCredentialsRelationship) { |
| 62 | + o.Oauth2ClientCredentials = &v |
| 63 | +} |
| 64 | + |
| 65 | +// MarshalJSON serializes the struct using spec logic. |
| 66 | +func (o WebhooksAuthMethodRelationships) MarshalJSON() ([]byte, error) { |
| 67 | + toSerialize := map[string]interface{}{} |
| 68 | + if o.UnparsedObject != nil { |
| 69 | + return datadog.Marshal(o.UnparsedObject) |
| 70 | + } |
| 71 | + if o.Oauth2ClientCredentials != nil { |
| 72 | + toSerialize["oauth2-client-credentials"] = o.Oauth2ClientCredentials |
| 73 | + } |
| 74 | + |
| 75 | + for key, value := range o.AdditionalProperties { |
| 76 | + toSerialize[key] = value |
| 77 | + } |
| 78 | + return datadog.Marshal(toSerialize) |
| 79 | +} |
| 80 | + |
| 81 | +// UnmarshalJSON deserializes the given payload. |
| 82 | +func (o *WebhooksAuthMethodRelationships) UnmarshalJSON(bytes []byte) (err error) { |
| 83 | + all := struct { |
| 84 | + Oauth2ClientCredentials *WebhooksOAuth2ClientCredentialsRelationship `json:"oauth2-client-credentials,omitempty"` |
| 85 | + }{} |
| 86 | + if err = datadog.Unmarshal(bytes, &all); err != nil { |
| 87 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 88 | + } |
| 89 | + additionalProperties := make(map[string]interface{}) |
| 90 | + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { |
| 91 | + datadog.DeleteKeys(additionalProperties, &[]string{"oauth2-client-credentials"}) |
| 92 | + } else { |
| 93 | + return err |
| 94 | + } |
| 95 | + |
| 96 | + hasInvalidField := false |
| 97 | + if all.Oauth2ClientCredentials != nil && all.Oauth2ClientCredentials.UnparsedObject != nil && o.UnparsedObject == nil { |
| 98 | + hasInvalidField = true |
| 99 | + } |
| 100 | + o.Oauth2ClientCredentials = all.Oauth2ClientCredentials |
| 101 | + |
| 102 | + if len(additionalProperties) > 0 { |
| 103 | + o.AdditionalProperties = additionalProperties |
| 104 | + } |
| 105 | + |
| 106 | + if hasInvalidField { |
| 107 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 108 | + } |
| 109 | + |
| 110 | + return nil |
| 111 | +} |
0 commit comments