-
Notifications
You must be signed in to change notification settings - Fork 54
/
model_image_widget_definition.go
416 lines (369 loc) · 13.2 KB
/
model_image_widget_definition.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.
package datadogV1
import (
"fmt"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
)
// ImageWidgetDefinition The image widget allows you to embed an image on your dashboard. An image can be a PNG, JPG, or animated GIF. Only available on FREE layout dashboards.
type ImageWidgetDefinition struct {
// Whether to display a background or not.
HasBackground *bool `json:"has_background,omitempty"`
// Whether to display a border or not.
HasBorder *bool `json:"has_border,omitempty"`
// Horizontal alignment.
HorizontalAlign *WidgetHorizontalAlign `json:"horizontal_align,omitempty"`
// Size of the margins around the image.
// **Note**: `small` and `large` values are deprecated.
Margin *WidgetMargin `json:"margin,omitempty"`
// How to size the image on the widget. The values are based on the image `object-fit` CSS properties.
// **Note**: `zoom`, `fit` and `center` values are deprecated.
Sizing *WidgetImageSizing `json:"sizing,omitempty"`
// Type of the image widget.
Type ImageWidgetDefinitionType `json:"type"`
// URL of the image.
Url string `json:"url"`
// URL of the image in dark mode.
UrlDarkTheme *string `json:"url_dark_theme,omitempty"`
// Vertical alignment.
VerticalAlign *WidgetVerticalAlign `json:"vertical_align,omitempty"`
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
UnparsedObject map[string]interface{} `json:"-"`
AdditionalProperties map[string]interface{}
}
// NewImageWidgetDefinition instantiates a new ImageWidgetDefinition object.
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed.
func NewImageWidgetDefinition(typeVar ImageWidgetDefinitionType, url string) *ImageWidgetDefinition {
this := ImageWidgetDefinition{}
var hasBackground bool = true
this.HasBackground = &hasBackground
var hasBorder bool = true
this.HasBorder = &hasBorder
this.Type = typeVar
this.Url = url
return &this
}
// NewImageWidgetDefinitionWithDefaults instantiates a new ImageWidgetDefinition object.
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set.
func NewImageWidgetDefinitionWithDefaults() *ImageWidgetDefinition {
this := ImageWidgetDefinition{}
var hasBackground bool = true
this.HasBackground = &hasBackground
var hasBorder bool = true
this.HasBorder = &hasBorder
var typeVar ImageWidgetDefinitionType = IMAGEWIDGETDEFINITIONTYPE_IMAGE
this.Type = typeVar
return &this
}
// GetHasBackground returns the HasBackground field value if set, zero value otherwise.
func (o *ImageWidgetDefinition) GetHasBackground() bool {
if o == nil || o.HasBackground == nil {
var ret bool
return ret
}
return *o.HasBackground
}
// GetHasBackgroundOk returns a tuple with the HasBackground field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *ImageWidgetDefinition) GetHasBackgroundOk() (*bool, bool) {
if o == nil || o.HasBackground == nil {
return nil, false
}
return o.HasBackground, true
}
// HasHasBackground returns a boolean if a field has been set.
func (o *ImageWidgetDefinition) HasHasBackground() bool {
return o != nil && o.HasBackground != nil
}
// SetHasBackground gets a reference to the given bool and assigns it to the HasBackground field.
func (o *ImageWidgetDefinition) SetHasBackground(v bool) {
o.HasBackground = &v
}
// GetHasBorder returns the HasBorder field value if set, zero value otherwise.
func (o *ImageWidgetDefinition) GetHasBorder() bool {
if o == nil || o.HasBorder == nil {
var ret bool
return ret
}
return *o.HasBorder
}
// GetHasBorderOk returns a tuple with the HasBorder field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *ImageWidgetDefinition) GetHasBorderOk() (*bool, bool) {
if o == nil || o.HasBorder == nil {
return nil, false
}
return o.HasBorder, true
}
// HasHasBorder returns a boolean if a field has been set.
func (o *ImageWidgetDefinition) HasHasBorder() bool {
return o != nil && o.HasBorder != nil
}
// SetHasBorder gets a reference to the given bool and assigns it to the HasBorder field.
func (o *ImageWidgetDefinition) SetHasBorder(v bool) {
o.HasBorder = &v
}
// GetHorizontalAlign returns the HorizontalAlign field value if set, zero value otherwise.
func (o *ImageWidgetDefinition) GetHorizontalAlign() WidgetHorizontalAlign {
if o == nil || o.HorizontalAlign == nil {
var ret WidgetHorizontalAlign
return ret
}
return *o.HorizontalAlign
}
// GetHorizontalAlignOk returns a tuple with the HorizontalAlign field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *ImageWidgetDefinition) GetHorizontalAlignOk() (*WidgetHorizontalAlign, bool) {
if o == nil || o.HorizontalAlign == nil {
return nil, false
}
return o.HorizontalAlign, true
}
// HasHorizontalAlign returns a boolean if a field has been set.
func (o *ImageWidgetDefinition) HasHorizontalAlign() bool {
return o != nil && o.HorizontalAlign != nil
}
// SetHorizontalAlign gets a reference to the given WidgetHorizontalAlign and assigns it to the HorizontalAlign field.
func (o *ImageWidgetDefinition) SetHorizontalAlign(v WidgetHorizontalAlign) {
o.HorizontalAlign = &v
}
// GetMargin returns the Margin field value if set, zero value otherwise.
func (o *ImageWidgetDefinition) GetMargin() WidgetMargin {
if o == nil || o.Margin == nil {
var ret WidgetMargin
return ret
}
return *o.Margin
}
// GetMarginOk returns a tuple with the Margin field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *ImageWidgetDefinition) GetMarginOk() (*WidgetMargin, bool) {
if o == nil || o.Margin == nil {
return nil, false
}
return o.Margin, true
}
// HasMargin returns a boolean if a field has been set.
func (o *ImageWidgetDefinition) HasMargin() bool {
return o != nil && o.Margin != nil
}
// SetMargin gets a reference to the given WidgetMargin and assigns it to the Margin field.
func (o *ImageWidgetDefinition) SetMargin(v WidgetMargin) {
o.Margin = &v
}
// GetSizing returns the Sizing field value if set, zero value otherwise.
func (o *ImageWidgetDefinition) GetSizing() WidgetImageSizing {
if o == nil || o.Sizing == nil {
var ret WidgetImageSizing
return ret
}
return *o.Sizing
}
// GetSizingOk returns a tuple with the Sizing field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *ImageWidgetDefinition) GetSizingOk() (*WidgetImageSizing, bool) {
if o == nil || o.Sizing == nil {
return nil, false
}
return o.Sizing, true
}
// HasSizing returns a boolean if a field has been set.
func (o *ImageWidgetDefinition) HasSizing() bool {
return o != nil && o.Sizing != nil
}
// SetSizing gets a reference to the given WidgetImageSizing and assigns it to the Sizing field.
func (o *ImageWidgetDefinition) SetSizing(v WidgetImageSizing) {
o.Sizing = &v
}
// GetType returns the Type field value.
func (o *ImageWidgetDefinition) GetType() ImageWidgetDefinitionType {
if o == nil {
var ret ImageWidgetDefinitionType
return ret
}
return o.Type
}
// GetTypeOk returns a tuple with the Type field value
// and a boolean to check if the value has been set.
func (o *ImageWidgetDefinition) GetTypeOk() (*ImageWidgetDefinitionType, bool) {
if o == nil {
return nil, false
}
return &o.Type, true
}
// SetType sets field value.
func (o *ImageWidgetDefinition) SetType(v ImageWidgetDefinitionType) {
o.Type = v
}
// GetUrl returns the Url field value.
func (o *ImageWidgetDefinition) GetUrl() string {
if o == nil {
var ret string
return ret
}
return o.Url
}
// GetUrlOk returns a tuple with the Url field value
// and a boolean to check if the value has been set.
func (o *ImageWidgetDefinition) GetUrlOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Url, true
}
// SetUrl sets field value.
func (o *ImageWidgetDefinition) SetUrl(v string) {
o.Url = v
}
// GetUrlDarkTheme returns the UrlDarkTheme field value if set, zero value otherwise.
func (o *ImageWidgetDefinition) GetUrlDarkTheme() string {
if o == nil || o.UrlDarkTheme == nil {
var ret string
return ret
}
return *o.UrlDarkTheme
}
// GetUrlDarkThemeOk returns a tuple with the UrlDarkTheme field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *ImageWidgetDefinition) GetUrlDarkThemeOk() (*string, bool) {
if o == nil || o.UrlDarkTheme == nil {
return nil, false
}
return o.UrlDarkTheme, true
}
// HasUrlDarkTheme returns a boolean if a field has been set.
func (o *ImageWidgetDefinition) HasUrlDarkTheme() bool {
return o != nil && o.UrlDarkTheme != nil
}
// SetUrlDarkTheme gets a reference to the given string and assigns it to the UrlDarkTheme field.
func (o *ImageWidgetDefinition) SetUrlDarkTheme(v string) {
o.UrlDarkTheme = &v
}
// GetVerticalAlign returns the VerticalAlign field value if set, zero value otherwise.
func (o *ImageWidgetDefinition) GetVerticalAlign() WidgetVerticalAlign {
if o == nil || o.VerticalAlign == nil {
var ret WidgetVerticalAlign
return ret
}
return *o.VerticalAlign
}
// GetVerticalAlignOk returns a tuple with the VerticalAlign field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *ImageWidgetDefinition) GetVerticalAlignOk() (*WidgetVerticalAlign, bool) {
if o == nil || o.VerticalAlign == nil {
return nil, false
}
return o.VerticalAlign, true
}
// HasVerticalAlign returns a boolean if a field has been set.
func (o *ImageWidgetDefinition) HasVerticalAlign() bool {
return o != nil && o.VerticalAlign != nil
}
// SetVerticalAlign gets a reference to the given WidgetVerticalAlign and assigns it to the VerticalAlign field.
func (o *ImageWidgetDefinition) SetVerticalAlign(v WidgetVerticalAlign) {
o.VerticalAlign = &v
}
// MarshalJSON serializes the struct using spec logic.
func (o ImageWidgetDefinition) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.UnparsedObject != nil {
return datadog.Marshal(o.UnparsedObject)
}
if o.HasBackground != nil {
toSerialize["has_background"] = o.HasBackground
}
if o.HasBorder != nil {
toSerialize["has_border"] = o.HasBorder
}
if o.HorizontalAlign != nil {
toSerialize["horizontal_align"] = o.HorizontalAlign
}
if o.Margin != nil {
toSerialize["margin"] = o.Margin
}
if o.Sizing != nil {
toSerialize["sizing"] = o.Sizing
}
toSerialize["type"] = o.Type
toSerialize["url"] = o.Url
if o.UrlDarkTheme != nil {
toSerialize["url_dark_theme"] = o.UrlDarkTheme
}
if o.VerticalAlign != nil {
toSerialize["vertical_align"] = o.VerticalAlign
}
for key, value := range o.AdditionalProperties {
toSerialize[key] = value
}
return datadog.Marshal(toSerialize)
}
// UnmarshalJSON deserializes the given payload.
func (o *ImageWidgetDefinition) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
HasBackground *bool `json:"has_background,omitempty"`
HasBorder *bool `json:"has_border,omitempty"`
HorizontalAlign *WidgetHorizontalAlign `json:"horizontal_align,omitempty"`
Margin *WidgetMargin `json:"margin,omitempty"`
Sizing *WidgetImageSizing `json:"sizing,omitempty"`
Type *ImageWidgetDefinitionType `json:"type"`
Url *string `json:"url"`
UrlDarkTheme *string `json:"url_dark_theme,omitempty"`
VerticalAlign *WidgetVerticalAlign `json:"vertical_align,omitempty"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
}
if all.Type == nil {
return fmt.Errorf("required field type missing")
}
if all.Url == nil {
return fmt.Errorf("required field url missing")
}
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"has_background", "has_border", "horizontal_align", "margin", "sizing", "type", "url", "url_dark_theme", "vertical_align"})
} else {
return err
}
hasInvalidField := false
o.HasBackground = all.HasBackground
o.HasBorder = all.HasBorder
if all.HorizontalAlign != nil && !all.HorizontalAlign.IsValid() {
hasInvalidField = true
} else {
o.HorizontalAlign = all.HorizontalAlign
}
if all.Margin != nil && !all.Margin.IsValid() {
hasInvalidField = true
} else {
o.Margin = all.Margin
}
if all.Sizing != nil && !all.Sizing.IsValid() {
hasInvalidField = true
} else {
o.Sizing = all.Sizing
}
if !all.Type.IsValid() {
hasInvalidField = true
} else {
o.Type = *all.Type
}
o.Url = *all.Url
o.UrlDarkTheme = all.UrlDarkTheme
if all.VerticalAlign != nil && !all.VerticalAlign.IsValid() {
hasInvalidField = true
} else {
o.VerticalAlign = all.VerticalAlign
}
if len(additionalProperties) > 0 {
o.AdditionalProperties = additionalProperties
}
if hasInvalidField {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
}
return nil
}