|
| 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 | +// MaxSessionDurationUpdateAttributes Attributes for the maximum session duration update request. |
| 14 | +type MaxSessionDurationUpdateAttributes struct { |
| 15 | + // The maximum session duration, in seconds. |
| 16 | + MaxSessionDuration int64 `json:"max_session_duration"` |
| 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 | +// NewMaxSessionDurationUpdateAttributes instantiates a new MaxSessionDurationUpdateAttributes 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 NewMaxSessionDurationUpdateAttributes(maxSessionDuration int64) *MaxSessionDurationUpdateAttributes { |
| 27 | + this := MaxSessionDurationUpdateAttributes{} |
| 28 | + this.MaxSessionDuration = maxSessionDuration |
| 29 | + return &this |
| 30 | +} |
| 31 | + |
| 32 | +// NewMaxSessionDurationUpdateAttributesWithDefaults instantiates a new MaxSessionDurationUpdateAttributes 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 NewMaxSessionDurationUpdateAttributesWithDefaults() *MaxSessionDurationUpdateAttributes { |
| 36 | + this := MaxSessionDurationUpdateAttributes{} |
| 37 | + return &this |
| 38 | +} |
| 39 | + |
| 40 | +// GetMaxSessionDuration returns the MaxSessionDuration field value. |
| 41 | +func (o *MaxSessionDurationUpdateAttributes) GetMaxSessionDuration() int64 { |
| 42 | + if o == nil { |
| 43 | + var ret int64 |
| 44 | + return ret |
| 45 | + } |
| 46 | + return o.MaxSessionDuration |
| 47 | +} |
| 48 | + |
| 49 | +// GetMaxSessionDurationOk returns a tuple with the MaxSessionDuration field value |
| 50 | +// and a boolean to check if the value has been set. |
| 51 | +func (o *MaxSessionDurationUpdateAttributes) GetMaxSessionDurationOk() (*int64, bool) { |
| 52 | + if o == nil { |
| 53 | + return nil, false |
| 54 | + } |
| 55 | + return &o.MaxSessionDuration, true |
| 56 | +} |
| 57 | + |
| 58 | +// SetMaxSessionDuration sets field value. |
| 59 | +func (o *MaxSessionDurationUpdateAttributes) SetMaxSessionDuration(v int64) { |
| 60 | + o.MaxSessionDuration = v |
| 61 | +} |
| 62 | + |
| 63 | +// MarshalJSON serializes the struct using spec logic. |
| 64 | +func (o MaxSessionDurationUpdateAttributes) MarshalJSON() ([]byte, error) { |
| 65 | + toSerialize := map[string]interface{}{} |
| 66 | + if o.UnparsedObject != nil { |
| 67 | + return datadog.Marshal(o.UnparsedObject) |
| 68 | + } |
| 69 | + toSerialize["max_session_duration"] = o.MaxSessionDuration |
| 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 *MaxSessionDurationUpdateAttributes) UnmarshalJSON(bytes []byte) (err error) { |
| 79 | + all := struct { |
| 80 | + MaxSessionDuration *int64 `json:"max_session_duration"` |
| 81 | + }{} |
| 82 | + if err = datadog.Unmarshal(bytes, &all); err != nil { |
| 83 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 84 | + } |
| 85 | + if all.MaxSessionDuration == nil { |
| 86 | + return fmt.Errorf("required field max_session_duration missing") |
| 87 | + } |
| 88 | + additionalProperties := make(map[string]interface{}) |
| 89 | + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { |
| 90 | + datadog.DeleteKeys(additionalProperties, &[]string{"max_session_duration"}) |
| 91 | + } else { |
| 92 | + return err |
| 93 | + } |
| 94 | + o.MaxSessionDuration = *all.MaxSessionDuration |
| 95 | + |
| 96 | + if len(additionalProperties) > 0 { |
| 97 | + o.AdditionalProperties = additionalProperties |
| 98 | + } |
| 99 | + |
| 100 | + return nil |
| 101 | +} |
0 commit comments