|
| 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 | + "fmt" |
| 9 | + |
| 10 | + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" |
| 11 | +) |
| 12 | + |
| 13 | +// ValidateV2Attributes Attributes of the API key validation response. |
| 14 | +type ValidateV2Attributes struct { |
| 15 | + // The UUID of the API key. |
| 16 | + ApiKeyId string `json:"api_key_id"` |
| 17 | + // List of scope names associated with the API key. |
| 18 | + ApiKeyScopes []string `json:"api_key_scopes"` |
| 19 | + // Whether the API key is valid. |
| 20 | + Valid bool `json:"valid"` |
| 21 | + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct |
| 22 | + UnparsedObject map[string]interface{} `json:"-"` |
| 23 | + AdditionalProperties map[string]interface{} `json:"-"` |
| 24 | +} |
| 25 | + |
| 26 | +// NewValidateV2Attributes instantiates a new ValidateV2Attributes object. |
| 27 | +// This constructor will assign default values to properties that have it defined, |
| 28 | +// and makes sure properties required by API are set, but the set of arguments |
| 29 | +// will change when the set of required properties is changed. |
| 30 | +func NewValidateV2Attributes(apiKeyId string, apiKeyScopes []string, valid bool) *ValidateV2Attributes { |
| 31 | + this := ValidateV2Attributes{} |
| 32 | + this.ApiKeyId = apiKeyId |
| 33 | + this.ApiKeyScopes = apiKeyScopes |
| 34 | + this.Valid = valid |
| 35 | + return &this |
| 36 | +} |
| 37 | + |
| 38 | +// NewValidateV2AttributesWithDefaults instantiates a new ValidateV2Attributes object. |
| 39 | +// This constructor will only assign default values to properties that have it defined, |
| 40 | +// but it doesn't guarantee that properties required by API are set. |
| 41 | +func NewValidateV2AttributesWithDefaults() *ValidateV2Attributes { |
| 42 | + this := ValidateV2Attributes{} |
| 43 | + return &this |
| 44 | +} |
| 45 | + |
| 46 | +// GetApiKeyId returns the ApiKeyId field value. |
| 47 | +func (o *ValidateV2Attributes) GetApiKeyId() string { |
| 48 | + if o == nil { |
| 49 | + var ret string |
| 50 | + return ret |
| 51 | + } |
| 52 | + return o.ApiKeyId |
| 53 | +} |
| 54 | + |
| 55 | +// GetApiKeyIdOk returns a tuple with the ApiKeyId field value |
| 56 | +// and a boolean to check if the value has been set. |
| 57 | +func (o *ValidateV2Attributes) GetApiKeyIdOk() (*string, bool) { |
| 58 | + if o == nil { |
| 59 | + return nil, false |
| 60 | + } |
| 61 | + return &o.ApiKeyId, true |
| 62 | +} |
| 63 | + |
| 64 | +// SetApiKeyId sets field value. |
| 65 | +func (o *ValidateV2Attributes) SetApiKeyId(v string) { |
| 66 | + o.ApiKeyId = v |
| 67 | +} |
| 68 | + |
| 69 | +// GetApiKeyScopes returns the ApiKeyScopes field value. |
| 70 | +func (o *ValidateV2Attributes) GetApiKeyScopes() []string { |
| 71 | + if o == nil { |
| 72 | + var ret []string |
| 73 | + return ret |
| 74 | + } |
| 75 | + return o.ApiKeyScopes |
| 76 | +} |
| 77 | + |
| 78 | +// GetApiKeyScopesOk returns a tuple with the ApiKeyScopes field value |
| 79 | +// and a boolean to check if the value has been set. |
| 80 | +func (o *ValidateV2Attributes) GetApiKeyScopesOk() (*[]string, bool) { |
| 81 | + if o == nil { |
| 82 | + return nil, false |
| 83 | + } |
| 84 | + return &o.ApiKeyScopes, true |
| 85 | +} |
| 86 | + |
| 87 | +// SetApiKeyScopes sets field value. |
| 88 | +func (o *ValidateV2Attributes) SetApiKeyScopes(v []string) { |
| 89 | + o.ApiKeyScopes = v |
| 90 | +} |
| 91 | + |
| 92 | +// GetValid returns the Valid field value. |
| 93 | +func (o *ValidateV2Attributes) GetValid() bool { |
| 94 | + if o == nil { |
| 95 | + var ret bool |
| 96 | + return ret |
| 97 | + } |
| 98 | + return o.Valid |
| 99 | +} |
| 100 | + |
| 101 | +// GetValidOk returns a tuple with the Valid field value |
| 102 | +// and a boolean to check if the value has been set. |
| 103 | +func (o *ValidateV2Attributes) GetValidOk() (*bool, bool) { |
| 104 | + if o == nil { |
| 105 | + return nil, false |
| 106 | + } |
| 107 | + return &o.Valid, true |
| 108 | +} |
| 109 | + |
| 110 | +// SetValid sets field value. |
| 111 | +func (o *ValidateV2Attributes) SetValid(v bool) { |
| 112 | + o.Valid = v |
| 113 | +} |
| 114 | + |
| 115 | +// MarshalJSON serializes the struct using spec logic. |
| 116 | +func (o ValidateV2Attributes) MarshalJSON() ([]byte, error) { |
| 117 | + toSerialize := map[string]interface{}{} |
| 118 | + if o.UnparsedObject != nil { |
| 119 | + return datadog.Marshal(o.UnparsedObject) |
| 120 | + } |
| 121 | + toSerialize["api_key_id"] = o.ApiKeyId |
| 122 | + toSerialize["api_key_scopes"] = o.ApiKeyScopes |
| 123 | + toSerialize["valid"] = o.Valid |
| 124 | + |
| 125 | + for key, value := range o.AdditionalProperties { |
| 126 | + toSerialize[key] = value |
| 127 | + } |
| 128 | + return datadog.Marshal(toSerialize) |
| 129 | +} |
| 130 | + |
| 131 | +// UnmarshalJSON deserializes the given payload. |
| 132 | +func (o *ValidateV2Attributes) UnmarshalJSON(bytes []byte) (err error) { |
| 133 | + all := struct { |
| 134 | + ApiKeyId *string `json:"api_key_id"` |
| 135 | + ApiKeyScopes *[]string `json:"api_key_scopes"` |
| 136 | + Valid *bool `json:"valid"` |
| 137 | + }{} |
| 138 | + if err = datadog.Unmarshal(bytes, &all); err != nil { |
| 139 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 140 | + } |
| 141 | + if all.ApiKeyId == nil { |
| 142 | + return fmt.Errorf("required field api_key_id missing") |
| 143 | + } |
| 144 | + if all.ApiKeyScopes == nil { |
| 145 | + return fmt.Errorf("required field api_key_scopes missing") |
| 146 | + } |
| 147 | + if all.Valid == nil { |
| 148 | + return fmt.Errorf("required field valid missing") |
| 149 | + } |
| 150 | + additionalProperties := make(map[string]interface{}) |
| 151 | + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { |
| 152 | + datadog.DeleteKeys(additionalProperties, &[]string{"api_key_id", "api_key_scopes", "valid"}) |
| 153 | + } else { |
| 154 | + return err |
| 155 | + } |
| 156 | + o.ApiKeyId = *all.ApiKeyId |
| 157 | + o.ApiKeyScopes = *all.ApiKeyScopes |
| 158 | + o.Valid = *all.Valid |
| 159 | + |
| 160 | + if len(additionalProperties) > 0 { |
| 161 | + o.AdditionalProperties = additionalProperties |
| 162 | + } |
| 163 | + |
| 164 | + return nil |
| 165 | +} |
0 commit comments