1 package scheduledqueryrules
2
3
4
5
6
7
8
9 import (
10 "context"
11 "encoding/json"
12 "github.com/Azure/go-autorest/autorest"
13 "github.com/Azure/go-autorest/autorest/date"
14 "github.com/Azure/go-autorest/autorest/to"
15 "github.com/Azure/go-autorest/tracing"
16 "net/http"
17 )
18
19
20 const fqdn = "github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2021-08-01/scheduledqueryrules"
21
22
23 type Actions struct {
24
25 ActionGroups *[]string `json:"actionGroups,omitempty"`
26
27 CustomProperties map[string]*string `json:"customProperties"`
28 }
29
30
31 func (a Actions) MarshalJSON() ([]byte, error) {
32 objectMap := make(map[string]interface{})
33 if a.ActionGroups != nil {
34 objectMap["actionGroups"] = a.ActionGroups
35 }
36 if a.CustomProperties != nil {
37 objectMap["customProperties"] = a.CustomProperties
38 }
39 return json.Marshal(objectMap)
40 }
41
42
43 type AzureEntityResource struct {
44
45 Etag *string `json:"etag,omitempty"`
46
47 ID *string `json:"id,omitempty"`
48
49 Name *string `json:"name,omitempty"`
50
51 Type *string `json:"type,omitempty"`
52 }
53
54
55 func (aer AzureEntityResource) MarshalJSON() ([]byte, error) {
56 objectMap := make(map[string]interface{})
57 return json.Marshal(objectMap)
58 }
59
60
61 type Condition struct {
62
63 Query *string `json:"query,omitempty"`
64
65 TimeAggregation TimeAggregation `json:"timeAggregation,omitempty"`
66
67 MetricMeasureColumn *string `json:"metricMeasureColumn,omitempty"`
68
69 ResourceIDColumn *string `json:"resourceIdColumn,omitempty"`
70
71 Dimensions *[]Dimension `json:"dimensions,omitempty"`
72
73 Operator ConditionOperator `json:"operator,omitempty"`
74
75 Threshold *float64 `json:"threshold,omitempty"`
76
77 FailingPeriods *ConditionFailingPeriods `json:"failingPeriods,omitempty"`
78
79 MetricName *string `json:"metricName,omitempty"`
80 }
81
82
83
84 type ConditionFailingPeriods struct {
85
86 NumberOfEvaluationPeriods *int64 `json:"numberOfEvaluationPeriods,omitempty"`
87
88 MinFailingPeriodsToAlert *int64 `json:"minFailingPeriodsToAlert,omitempty"`
89 }
90
91
92 type Criteria struct {
93
94 AllOf *[]Condition `json:"allOf,omitempty"`
95 }
96
97
98 type Dimension struct {
99
100 Name *string `json:"name,omitempty"`
101
102 Operator DimensionOperator `json:"operator,omitempty"`
103
104 Values *[]string `json:"values,omitempty"`
105 }
106
107
108 type ErrorAdditionalInfo struct {
109
110 Type *string `json:"type,omitempty"`
111
112 Info interface{} `json:"info,omitempty"`
113 }
114
115
116 func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) {
117 objectMap := make(map[string]interface{})
118 return json.Marshal(objectMap)
119 }
120
121
122 type ErrorContract struct {
123
124 Error *ErrorResponse `json:"error,omitempty"`
125 }
126
127
128
129 type ErrorResponse struct {
130
131 Code *string `json:"code,omitempty"`
132
133 Message *string `json:"message,omitempty"`
134
135 Target *string `json:"target,omitempty"`
136
137 Details *[]ErrorResponse `json:"details,omitempty"`
138
139 AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"`
140 }
141
142
143 func (er ErrorResponse) MarshalJSON() ([]byte, error) {
144 objectMap := make(map[string]interface{})
145 return json.Marshal(objectMap)
146 }
147
148
149 type Properties struct {
150
151 CreatedWithAPIVersion *string `json:"createdWithApiVersion,omitempty"`
152
153 IsLegacyLogAnalyticsRule *bool `json:"isLegacyLogAnalyticsRule,omitempty"`
154
155 Description *string `json:"description,omitempty"`
156
157 DisplayName *string `json:"displayName,omitempty"`
158
159 Severity *int64 `json:"severity,omitempty"`
160
161 Enabled *bool `json:"enabled,omitempty"`
162
163 Scopes *[]string `json:"scopes,omitempty"`
164
165 EvaluationFrequency *string `json:"evaluationFrequency,omitempty"`
166
167 WindowSize *string `json:"windowSize,omitempty"`
168
169 OverrideQueryTimeRange *string `json:"overrideQueryTimeRange,omitempty"`
170
171 TargetResourceTypes *[]string `json:"targetResourceTypes,omitempty"`
172
173 Criteria *Criteria `json:"criteria,omitempty"`
174
175 MuteActionsDuration *string `json:"muteActionsDuration,omitempty"`
176
177 Actions *Actions `json:"actions,omitempty"`
178
179 IsWorkspaceAlertsStorageConfigured *bool `json:"isWorkspaceAlertsStorageConfigured,omitempty"`
180
181 CheckWorkspaceAlertsStorageConfigured *bool `json:"checkWorkspaceAlertsStorageConfigured,omitempty"`
182
183 SkipQueryValidation *bool `json:"skipQueryValidation,omitempty"`
184
185 AutoMitigate *bool `json:"autoMitigate,omitempty"`
186 }
187
188
189 func (p Properties) MarshalJSON() ([]byte, error) {
190 objectMap := make(map[string]interface{})
191 if p.Description != nil {
192 objectMap["description"] = p.Description
193 }
194 if p.DisplayName != nil {
195 objectMap["displayName"] = p.DisplayName
196 }
197 if p.Severity != nil {
198 objectMap["severity"] = p.Severity
199 }
200 if p.Enabled != nil {
201 objectMap["enabled"] = p.Enabled
202 }
203 if p.Scopes != nil {
204 objectMap["scopes"] = p.Scopes
205 }
206 if p.EvaluationFrequency != nil {
207 objectMap["evaluationFrequency"] = p.EvaluationFrequency
208 }
209 if p.WindowSize != nil {
210 objectMap["windowSize"] = p.WindowSize
211 }
212 if p.OverrideQueryTimeRange != nil {
213 objectMap["overrideQueryTimeRange"] = p.OverrideQueryTimeRange
214 }
215 if p.TargetResourceTypes != nil {
216 objectMap["targetResourceTypes"] = p.TargetResourceTypes
217 }
218 if p.Criteria != nil {
219 objectMap["criteria"] = p.Criteria
220 }
221 if p.MuteActionsDuration != nil {
222 objectMap["muteActionsDuration"] = p.MuteActionsDuration
223 }
224 if p.Actions != nil {
225 objectMap["actions"] = p.Actions
226 }
227 if p.CheckWorkspaceAlertsStorageConfigured != nil {
228 objectMap["checkWorkspaceAlertsStorageConfigured"] = p.CheckWorkspaceAlertsStorageConfigured
229 }
230 if p.SkipQueryValidation != nil {
231 objectMap["skipQueryValidation"] = p.SkipQueryValidation
232 }
233 if p.AutoMitigate != nil {
234 objectMap["autoMitigate"] = p.AutoMitigate
235 }
236 return json.Marshal(objectMap)
237 }
238
239
240
241 type ProxyResource struct {
242
243 ID *string `json:"id,omitempty"`
244
245 Name *string `json:"name,omitempty"`
246
247 Type *string `json:"type,omitempty"`
248 }
249
250
251 func (pr ProxyResource) MarshalJSON() ([]byte, error) {
252 objectMap := make(map[string]interface{})
253 return json.Marshal(objectMap)
254 }
255
256
257 type Resource struct {
258
259 ID *string `json:"id,omitempty"`
260
261 Name *string `json:"name,omitempty"`
262
263 Type *string `json:"type,omitempty"`
264 }
265
266
267 func (r Resource) MarshalJSON() ([]byte, error) {
268 objectMap := make(map[string]interface{})
269 return json.Marshal(objectMap)
270 }
271
272
273 type ResourceCollection struct {
274 autorest.Response `json:"-"`
275
276 Value *[]ResourceType `json:"value,omitempty"`
277
278 NextLink *string `json:"nextLink,omitempty"`
279 }
280
281
282 func (rc ResourceCollection) MarshalJSON() ([]byte, error) {
283 objectMap := make(map[string]interface{})
284 if rc.Value != nil {
285 objectMap["value"] = rc.Value
286 }
287 return json.Marshal(objectMap)
288 }
289
290
291 type ResourceCollectionIterator struct {
292 i int
293 page ResourceCollectionPage
294 }
295
296
297
298 func (iter *ResourceCollectionIterator) NextWithContext(ctx context.Context) (err error) {
299 if tracing.IsEnabled() {
300 ctx = tracing.StartSpan(ctx, fqdn+"/ResourceCollectionIterator.NextWithContext")
301 defer func() {
302 sc := -1
303 if iter.Response().Response.Response != nil {
304 sc = iter.Response().Response.Response.StatusCode
305 }
306 tracing.EndSpan(ctx, sc, err)
307 }()
308 }
309 iter.i++
310 if iter.i < len(iter.page.Values()) {
311 return nil
312 }
313 err = iter.page.NextWithContext(ctx)
314 if err != nil {
315 iter.i--
316 return err
317 }
318 iter.i = 0
319 return nil
320 }
321
322
323
324
325 func (iter *ResourceCollectionIterator) Next() error {
326 return iter.NextWithContext(context.Background())
327 }
328
329
330 func (iter ResourceCollectionIterator) NotDone() bool {
331 return iter.page.NotDone() && iter.i < len(iter.page.Values())
332 }
333
334
335 func (iter ResourceCollectionIterator) Response() ResourceCollection {
336 return iter.page.Response()
337 }
338
339
340
341 func (iter ResourceCollectionIterator) Value() ResourceType {
342 if !iter.page.NotDone() {
343 return ResourceType{}
344 }
345 return iter.page.Values()[iter.i]
346 }
347
348
349 func NewResourceCollectionIterator(page ResourceCollectionPage) ResourceCollectionIterator {
350 return ResourceCollectionIterator{page: page}
351 }
352
353
354 func (rc ResourceCollection) IsEmpty() bool {
355 return rc.Value == nil || len(*rc.Value) == 0
356 }
357
358
359 func (rc ResourceCollection) hasNextLink() bool {
360 return rc.NextLink != nil && len(*rc.NextLink) != 0
361 }
362
363
364
365 func (rc ResourceCollection) resourceCollectionPreparer(ctx context.Context) (*http.Request, error) {
366 if !rc.hasNextLink() {
367 return nil, nil
368 }
369 return autorest.Prepare((&http.Request{}).WithContext(ctx),
370 autorest.AsJSON(),
371 autorest.AsGet(),
372 autorest.WithBaseURL(to.String(rc.NextLink)))
373 }
374
375
376 type ResourceCollectionPage struct {
377 fn func(context.Context, ResourceCollection) (ResourceCollection, error)
378 rc ResourceCollection
379 }
380
381
382
383 func (page *ResourceCollectionPage) NextWithContext(ctx context.Context) (err error) {
384 if tracing.IsEnabled() {
385 ctx = tracing.StartSpan(ctx, fqdn+"/ResourceCollectionPage.NextWithContext")
386 defer func() {
387 sc := -1
388 if page.Response().Response.Response != nil {
389 sc = page.Response().Response.Response.StatusCode
390 }
391 tracing.EndSpan(ctx, sc, err)
392 }()
393 }
394 for {
395 next, err := page.fn(ctx, page.rc)
396 if err != nil {
397 return err
398 }
399 page.rc = next
400 if !next.hasNextLink() || !next.IsEmpty() {
401 break
402 }
403 }
404 return nil
405 }
406
407
408
409
410 func (page *ResourceCollectionPage) Next() error {
411 return page.NextWithContext(context.Background())
412 }
413
414
415 func (page ResourceCollectionPage) NotDone() bool {
416 return !page.rc.IsEmpty()
417 }
418
419
420 func (page ResourceCollectionPage) Response() ResourceCollection {
421 return page.rc
422 }
423
424
425 func (page ResourceCollectionPage) Values() []ResourceType {
426 if page.rc.IsEmpty() {
427 return nil
428 }
429 return *page.rc.Value
430 }
431
432
433 func NewResourceCollectionPage(cur ResourceCollection, getNextPage func(context.Context, ResourceCollection) (ResourceCollection, error)) ResourceCollectionPage {
434 return ResourceCollectionPage{
435 fn: getNextPage,
436 rc: cur,
437 }
438 }
439
440
441 type ResourcePatch struct {
442
443 Tags map[string]*string `json:"tags"`
444
445 *Properties `json:"properties,omitempty"`
446 }
447
448
449 func (rp ResourcePatch) MarshalJSON() ([]byte, error) {
450 objectMap := make(map[string]interface{})
451 if rp.Tags != nil {
452 objectMap["tags"] = rp.Tags
453 }
454 if rp.Properties != nil {
455 objectMap["properties"] = rp.Properties
456 }
457 return json.Marshal(objectMap)
458 }
459
460
461 func (rp *ResourcePatch) UnmarshalJSON(body []byte) error {
462 var m map[string]*json.RawMessage
463 err := json.Unmarshal(body, &m)
464 if err != nil {
465 return err
466 }
467 for k, v := range m {
468 switch k {
469 case "tags":
470 if v != nil {
471 var tags map[string]*string
472 err = json.Unmarshal(*v, &tags)
473 if err != nil {
474 return err
475 }
476 rp.Tags = tags
477 }
478 case "properties":
479 if v != nil {
480 var properties Properties
481 err = json.Unmarshal(*v, &properties)
482 if err != nil {
483 return err
484 }
485 rp.Properties = &properties
486 }
487 }
488 }
489
490 return nil
491 }
492
493
494 type ResourceType struct {
495 autorest.Response `json:"-"`
496
497 Kind Kind `json:"kind,omitempty"`
498
499 Etag *string `json:"etag,omitempty"`
500
501 SystemData *SystemData `json:"systemData,omitempty"`
502
503 *Properties `json:"properties,omitempty"`
504
505 Tags map[string]*string `json:"tags"`
506
507 Location *string `json:"location,omitempty"`
508
509 ID *string `json:"id,omitempty"`
510
511 Name *string `json:"name,omitempty"`
512
513 Type *string `json:"type,omitempty"`
514 }
515
516
517 func (rt ResourceType) MarshalJSON() ([]byte, error) {
518 objectMap := make(map[string]interface{})
519 if rt.Kind != "" {
520 objectMap["kind"] = rt.Kind
521 }
522 if rt.Properties != nil {
523 objectMap["properties"] = rt.Properties
524 }
525 if rt.Tags != nil {
526 objectMap["tags"] = rt.Tags
527 }
528 if rt.Location != nil {
529 objectMap["location"] = rt.Location
530 }
531 return json.Marshal(objectMap)
532 }
533
534
535 func (rt *ResourceType) UnmarshalJSON(body []byte) error {
536 var m map[string]*json.RawMessage
537 err := json.Unmarshal(body, &m)
538 if err != nil {
539 return err
540 }
541 for k, v := range m {
542 switch k {
543 case "kind":
544 if v != nil {
545 var kind Kind
546 err = json.Unmarshal(*v, &kind)
547 if err != nil {
548 return err
549 }
550 rt.Kind = kind
551 }
552 case "etag":
553 if v != nil {
554 var etag string
555 err = json.Unmarshal(*v, &etag)
556 if err != nil {
557 return err
558 }
559 rt.Etag = &etag
560 }
561 case "systemData":
562 if v != nil {
563 var systemData SystemData
564 err = json.Unmarshal(*v, &systemData)
565 if err != nil {
566 return err
567 }
568 rt.SystemData = &systemData
569 }
570 case "properties":
571 if v != nil {
572 var properties Properties
573 err = json.Unmarshal(*v, &properties)
574 if err != nil {
575 return err
576 }
577 rt.Properties = &properties
578 }
579 case "tags":
580 if v != nil {
581 var tags map[string]*string
582 err = json.Unmarshal(*v, &tags)
583 if err != nil {
584 return err
585 }
586 rt.Tags = tags
587 }
588 case "location":
589 if v != nil {
590 var location string
591 err = json.Unmarshal(*v, &location)
592 if err != nil {
593 return err
594 }
595 rt.Location = &location
596 }
597 case "id":
598 if v != nil {
599 var ID string
600 err = json.Unmarshal(*v, &ID)
601 if err != nil {
602 return err
603 }
604 rt.ID = &ID
605 }
606 case "name":
607 if v != nil {
608 var name string
609 err = json.Unmarshal(*v, &name)
610 if err != nil {
611 return err
612 }
613 rt.Name = &name
614 }
615 case "type":
616 if v != nil {
617 var typeVar string
618 err = json.Unmarshal(*v, &typeVar)
619 if err != nil {
620 return err
621 }
622 rt.Type = &typeVar
623 }
624 }
625 }
626
627 return nil
628 }
629
630
631 type SystemData struct {
632
633 CreatedBy *string `json:"createdBy,omitempty"`
634
635 CreatedByType CreatedByType `json:"createdByType,omitempty"`
636
637 CreatedAt *date.Time `json:"createdAt,omitempty"`
638
639 LastModifiedBy *string `json:"lastModifiedBy,omitempty"`
640
641 LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"`
642
643 LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"`
644 }
645
646
647
648 type TrackedResource struct {
649
650 Tags map[string]*string `json:"tags"`
651
652 Location *string `json:"location,omitempty"`
653
654 ID *string `json:"id,omitempty"`
655
656 Name *string `json:"name,omitempty"`
657
658 Type *string `json:"type,omitempty"`
659 }
660
661
662 func (tr TrackedResource) MarshalJSON() ([]byte, error) {
663 objectMap := make(map[string]interface{})
664 if tr.Tags != nil {
665 objectMap["tags"] = tr.Tags
666 }
667 if tr.Location != nil {
668 objectMap["location"] = tr.Location
669 }
670 return json.Marshal(objectMap)
671 }
672
View as plain text