|
| 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 | +// AWSIntegrationIamPermissionsResponseAttributes AWS Integration IAM Permissions response attributes. |
| 14 | +type AWSIntegrationIamPermissionsResponseAttributes struct { |
| 15 | + // List of AWS IAM permissions required for the integration. |
| 16 | + Permissions []string `json:"permissions"` |
| 17 | + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct |
| 18 | + UnparsedObject map[string]interface{} `json:"-"` |
| 19 | + AdditionalProperties map[string]interface{} `json:"-"` |
| 20 | +} |
| 21 | + |
| 22 | +// NewAWSIntegrationIamPermissionsResponseAttributes instantiates a new AWSIntegrationIamPermissionsResponseAttributes object. |
| 23 | +// This constructor will assign default values to properties that have it defined, |
| 24 | +// and makes sure properties required by API are set, but the set of arguments |
| 25 | +// will change when the set of required properties is changed. |
| 26 | +func NewAWSIntegrationIamPermissionsResponseAttributes(permissions []string) *AWSIntegrationIamPermissionsResponseAttributes { |
| 27 | + this := AWSIntegrationIamPermissionsResponseAttributes{} |
| 28 | + this.Permissions = permissions |
| 29 | + return &this |
| 30 | +} |
| 31 | + |
| 32 | +// NewAWSIntegrationIamPermissionsResponseAttributesWithDefaults instantiates a new AWSIntegrationIamPermissionsResponseAttributes object. |
| 33 | +// This constructor will only assign default values to properties that have it defined, |
| 34 | +// but it doesn't guarantee that properties required by API are set. |
| 35 | +func NewAWSIntegrationIamPermissionsResponseAttributesWithDefaults() *AWSIntegrationIamPermissionsResponseAttributes { |
| 36 | + this := AWSIntegrationIamPermissionsResponseAttributes{} |
| 37 | + return &this |
| 38 | +} |
| 39 | + |
| 40 | +// GetPermissions returns the Permissions field value. |
| 41 | +func (o *AWSIntegrationIamPermissionsResponseAttributes) GetPermissions() []string { |
| 42 | + if o == nil { |
| 43 | + var ret []string |
| 44 | + return ret |
| 45 | + } |
| 46 | + return o.Permissions |
| 47 | +} |
| 48 | + |
| 49 | +// GetPermissionsOk returns a tuple with the Permissions field value |
| 50 | +// and a boolean to check if the value has been set. |
| 51 | +func (o *AWSIntegrationIamPermissionsResponseAttributes) GetPermissionsOk() (*[]string, bool) { |
| 52 | + if o == nil { |
| 53 | + return nil, false |
| 54 | + } |
| 55 | + return &o.Permissions, true |
| 56 | +} |
| 57 | + |
| 58 | +// SetPermissions sets field value. |
| 59 | +func (o *AWSIntegrationIamPermissionsResponseAttributes) SetPermissions(v []string) { |
| 60 | + o.Permissions = v |
| 61 | +} |
| 62 | + |
| 63 | +// MarshalJSON serializes the struct using spec logic. |
| 64 | +func (o AWSIntegrationIamPermissionsResponseAttributes) MarshalJSON() ([]byte, error) { |
| 65 | + toSerialize := map[string]interface{}{} |
| 66 | + if o.UnparsedObject != nil { |
| 67 | + return datadog.Marshal(o.UnparsedObject) |
| 68 | + } |
| 69 | + toSerialize["permissions"] = o.Permissions |
| 70 | + |
| 71 | + for key, value := range o.AdditionalProperties { |
| 72 | + toSerialize[key] = value |
| 73 | + } |
| 74 | + return datadog.Marshal(toSerialize) |
| 75 | +} |
| 76 | + |
| 77 | +// UnmarshalJSON deserializes the given payload. |
| 78 | +func (o *AWSIntegrationIamPermissionsResponseAttributes) UnmarshalJSON(bytes []byte) (err error) { |
| 79 | + all := struct { |
| 80 | + Permissions *[]string `json:"permissions"` |
| 81 | + }{} |
| 82 | + if err = datadog.Unmarshal(bytes, &all); err != nil { |
| 83 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 84 | + } |
| 85 | + if all.Permissions == nil { |
| 86 | + return fmt.Errorf("required field permissions missing") |
| 87 | + } |
| 88 | + additionalProperties := make(map[string]interface{}) |
| 89 | + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { |
| 90 | + datadog.DeleteKeys(additionalProperties, &[]string{"permissions"}) |
| 91 | + } else { |
| 92 | + return err |
| 93 | + } |
| 94 | + o.Permissions = *all.Permissions |
| 95 | + |
| 96 | + if len(additionalProperties) > 0 { |
| 97 | + o.AdditionalProperties = additionalProperties |
| 98 | + } |
| 99 | + |
| 100 | + return nil |
| 101 | +} |
0 commit comments