|
| 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 datadogV1 |
| 6 | + |
| 7 | +import ( |
| 8 | + "fmt" |
| 9 | + |
| 10 | + "github.com/google/uuid" |
| 11 | + |
| 12 | + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" |
| 13 | +) |
| 14 | + |
| 15 | +// DashboardTab Dashboard tab for organizing widgets. |
| 16 | +type DashboardTab struct { |
| 17 | + // UUID of the tab. |
| 18 | + Id uuid.UUID `json:"id"` |
| 19 | + // Name of the tab. |
| 20 | + Name string `json:"name"` |
| 21 | + // List of widget IDs belonging to this tab. The backend also accepts positional references in @N format (1-indexed) as a convenience for Terraform and other declarative tools. |
| 22 | + WidgetIds []int64 `json:"widget_ids"` |
| 23 | + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct |
| 24 | + UnparsedObject map[string]interface{} `json:"-"` |
| 25 | + AdditionalProperties map[string]interface{} `json:"-"` |
| 26 | +} |
| 27 | + |
| 28 | +// NewDashboardTab instantiates a new DashboardTab object. |
| 29 | +// This constructor will assign default values to properties that have it defined, |
| 30 | +// and makes sure properties required by API are set, but the set of arguments |
| 31 | +// will change when the set of required properties is changed. |
| 32 | +func NewDashboardTab(id uuid.UUID, name string, widgetIds []int64) *DashboardTab { |
| 33 | + this := DashboardTab{} |
| 34 | + this.Id = id |
| 35 | + this.Name = name |
| 36 | + this.WidgetIds = widgetIds |
| 37 | + return &this |
| 38 | +} |
| 39 | + |
| 40 | +// NewDashboardTabWithDefaults instantiates a new DashboardTab object. |
| 41 | +// This constructor will only assign default values to properties that have it defined, |
| 42 | +// but it doesn't guarantee that properties required by API are set. |
| 43 | +func NewDashboardTabWithDefaults() *DashboardTab { |
| 44 | + this := DashboardTab{} |
| 45 | + return &this |
| 46 | +} |
| 47 | + |
| 48 | +// GetId returns the Id field value. |
| 49 | +func (o *DashboardTab) GetId() uuid.UUID { |
| 50 | + if o == nil { |
| 51 | + var ret uuid.UUID |
| 52 | + return ret |
| 53 | + } |
| 54 | + return o.Id |
| 55 | +} |
| 56 | + |
| 57 | +// GetIdOk returns a tuple with the Id field value |
| 58 | +// and a boolean to check if the value has been set. |
| 59 | +func (o *DashboardTab) GetIdOk() (*uuid.UUID, bool) { |
| 60 | + if o == nil { |
| 61 | + return nil, false |
| 62 | + } |
| 63 | + return &o.Id, true |
| 64 | +} |
| 65 | + |
| 66 | +// SetId sets field value. |
| 67 | +func (o *DashboardTab) SetId(v uuid.UUID) { |
| 68 | + o.Id = v |
| 69 | +} |
| 70 | + |
| 71 | +// GetName returns the Name field value. |
| 72 | +func (o *DashboardTab) GetName() string { |
| 73 | + if o == nil { |
| 74 | + var ret string |
| 75 | + return ret |
| 76 | + } |
| 77 | + return o.Name |
| 78 | +} |
| 79 | + |
| 80 | +// GetNameOk returns a tuple with the Name field value |
| 81 | +// and a boolean to check if the value has been set. |
| 82 | +func (o *DashboardTab) GetNameOk() (*string, bool) { |
| 83 | + if o == nil { |
| 84 | + return nil, false |
| 85 | + } |
| 86 | + return &o.Name, true |
| 87 | +} |
| 88 | + |
| 89 | +// SetName sets field value. |
| 90 | +func (o *DashboardTab) SetName(v string) { |
| 91 | + o.Name = v |
| 92 | +} |
| 93 | + |
| 94 | +// GetWidgetIds returns the WidgetIds field value. |
| 95 | +func (o *DashboardTab) GetWidgetIds() []int64 { |
| 96 | + if o == nil { |
| 97 | + var ret []int64 |
| 98 | + return ret |
| 99 | + } |
| 100 | + return o.WidgetIds |
| 101 | +} |
| 102 | + |
| 103 | +// GetWidgetIdsOk returns a tuple with the WidgetIds field value |
| 104 | +// and a boolean to check if the value has been set. |
| 105 | +func (o *DashboardTab) GetWidgetIdsOk() (*[]int64, bool) { |
| 106 | + if o == nil { |
| 107 | + return nil, false |
| 108 | + } |
| 109 | + return &o.WidgetIds, true |
| 110 | +} |
| 111 | + |
| 112 | +// SetWidgetIds sets field value. |
| 113 | +func (o *DashboardTab) SetWidgetIds(v []int64) { |
| 114 | + o.WidgetIds = v |
| 115 | +} |
| 116 | + |
| 117 | +// MarshalJSON serializes the struct using spec logic. |
| 118 | +func (o DashboardTab) MarshalJSON() ([]byte, error) { |
| 119 | + toSerialize := map[string]interface{}{} |
| 120 | + if o.UnparsedObject != nil { |
| 121 | + return datadog.Marshal(o.UnparsedObject) |
| 122 | + } |
| 123 | + toSerialize["id"] = o.Id |
| 124 | + toSerialize["name"] = o.Name |
| 125 | + toSerialize["widget_ids"] = o.WidgetIds |
| 126 | + |
| 127 | + for key, value := range o.AdditionalProperties { |
| 128 | + toSerialize[key] = value |
| 129 | + } |
| 130 | + return datadog.Marshal(toSerialize) |
| 131 | +} |
| 132 | + |
| 133 | +// UnmarshalJSON deserializes the given payload. |
| 134 | +func (o *DashboardTab) UnmarshalJSON(bytes []byte) (err error) { |
| 135 | + all := struct { |
| 136 | + Id *uuid.UUID `json:"id"` |
| 137 | + Name *string `json:"name"` |
| 138 | + WidgetIds *[]int64 `json:"widget_ids"` |
| 139 | + }{} |
| 140 | + if err = datadog.Unmarshal(bytes, &all); err != nil { |
| 141 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 142 | + } |
| 143 | + if all.Id == nil { |
| 144 | + return fmt.Errorf("required field id missing") |
| 145 | + } |
| 146 | + if all.Name == nil { |
| 147 | + return fmt.Errorf("required field name missing") |
| 148 | + } |
| 149 | + if all.WidgetIds == nil { |
| 150 | + return fmt.Errorf("required field widget_ids missing") |
| 151 | + } |
| 152 | + additionalProperties := make(map[string]interface{}) |
| 153 | + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { |
| 154 | + datadog.DeleteKeys(additionalProperties, &[]string{"id", "name", "widget_ids"}) |
| 155 | + } else { |
| 156 | + return err |
| 157 | + } |
| 158 | + o.Id = *all.Id |
| 159 | + o.Name = *all.Name |
| 160 | + o.WidgetIds = *all.WidgetIds |
| 161 | + |
| 162 | + if len(additionalProperties) > 0 { |
| 163 | + o.AdditionalProperties = additionalProperties |
| 164 | + } |
| 165 | + |
| 166 | + return nil |
| 167 | +} |
0 commit comments