1package changeanalysis
2
3// Copyright (c) Microsoft Corporation. All rights reserved.
4// Licensed under the MIT License. See License.txt in the project root for license information.
5//
6// Code generated by Microsoft (R) AutoRest Code Generator.
7// Changes may cause incorrect behavior and will be lost if the code is regenerated.
8
9import (
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// The package's fully qualified name.
20const fqdn = "github.com/Azure/azure-sdk-for-go/services/changeanalysis/mgmt/2021-04-01/changeanalysis"
21
22// AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag.
23type AzureEntityResource struct {
24	// Etag - READ-ONLY; Resource Etag.
25	Etag *string `json:"etag,omitempty"`
26	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
27	ID *string `json:"id,omitempty"`
28	// Name - READ-ONLY; The name of the resource
29	Name *string `json:"name,omitempty"`
30	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
31	Type *string `json:"type,omitempty"`
32}
33
34// MarshalJSON is the custom marshaler for AzureEntityResource.
35func (aer AzureEntityResource) MarshalJSON() ([]byte, error) {
36	objectMap := make(map[string]interface{})
37	return json.Marshal(objectMap)
38}
39
40// Change the detected change.
41type Change struct {
42	Properties *ChangeProperties `json:"properties,omitempty"`
43	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
44	ID *string `json:"id,omitempty"`
45	// Name - READ-ONLY; The name of the resource
46	Name *string `json:"name,omitempty"`
47	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
48	Type *string `json:"type,omitempty"`
49}
50
51// MarshalJSON is the custom marshaler for Change.
52func (c Change) MarshalJSON() ([]byte, error) {
53	objectMap := make(map[string]interface{})
54	if c.Properties != nil {
55		objectMap["properties"] = c.Properties
56	}
57	return json.Marshal(objectMap)
58}
59
60// ChangeList the list of detected changes.
61type ChangeList struct {
62	autorest.Response `json:"-"`
63	// Value - The list of changes.
64	Value *[]Change `json:"value,omitempty"`
65	// NextLink - The URI that can be used to request the next page of changes.
66	NextLink *string `json:"nextLink,omitempty"`
67}
68
69// ChangeListIterator provides access to a complete listing of Change values.
70type ChangeListIterator struct {
71	i    int
72	page ChangeListPage
73}
74
75// NextWithContext advances to the next value.  If there was an error making
76// the request the iterator does not advance and the error is returned.
77func (iter *ChangeListIterator) NextWithContext(ctx context.Context) (err error) {
78	if tracing.IsEnabled() {
79		ctx = tracing.StartSpan(ctx, fqdn+"/ChangeListIterator.NextWithContext")
80		defer func() {
81			sc := -1
82			if iter.Response().Response.Response != nil {
83				sc = iter.Response().Response.Response.StatusCode
84			}
85			tracing.EndSpan(ctx, sc, err)
86		}()
87	}
88	iter.i++
89	if iter.i < len(iter.page.Values()) {
90		return nil
91	}
92	err = iter.page.NextWithContext(ctx)
93	if err != nil {
94		iter.i--
95		return err
96	}
97	iter.i = 0
98	return nil
99}
100
101// Next advances to the next value.  If there was an error making
102// the request the iterator does not advance and the error is returned.
103// Deprecated: Use NextWithContext() instead.
104func (iter *ChangeListIterator) Next() error {
105	return iter.NextWithContext(context.Background())
106}
107
108// NotDone returns true if the enumeration should be started or is not yet complete.
109func (iter ChangeListIterator) NotDone() bool {
110	return iter.page.NotDone() && iter.i < len(iter.page.Values())
111}
112
113// Response returns the raw server response from the last page request.
114func (iter ChangeListIterator) Response() ChangeList {
115	return iter.page.Response()
116}
117
118// Value returns the current value or a zero-initialized value if the
119// iterator has advanced beyond the end of the collection.
120func (iter ChangeListIterator) Value() Change {
121	if !iter.page.NotDone() {
122		return Change{}
123	}
124	return iter.page.Values()[iter.i]
125}
126
127// Creates a new instance of the ChangeListIterator type.
128func NewChangeListIterator(page ChangeListPage) ChangeListIterator {
129	return ChangeListIterator{page: page}
130}
131
132// IsEmpty returns true if the ListResult contains no values.
133func (cl ChangeList) IsEmpty() bool {
134	return cl.Value == nil || len(*cl.Value) == 0
135}
136
137// hasNextLink returns true if the NextLink is not empty.
138func (cl ChangeList) hasNextLink() bool {
139	return cl.NextLink != nil && len(*cl.NextLink) != 0
140}
141
142// changeListPreparer prepares a request to retrieve the next set of results.
143// It returns nil if no more results exist.
144func (cl ChangeList) changeListPreparer(ctx context.Context) (*http.Request, error) {
145	if !cl.hasNextLink() {
146		return nil, nil
147	}
148	return autorest.Prepare((&http.Request{}).WithContext(ctx),
149		autorest.AsJSON(),
150		autorest.AsGet(),
151		autorest.WithBaseURL(to.String(cl.NextLink)))
152}
153
154// ChangeListPage contains a page of Change values.
155type ChangeListPage struct {
156	fn func(context.Context, ChangeList) (ChangeList, error)
157	cl ChangeList
158}
159
160// NextWithContext advances to the next page of values.  If there was an error making
161// the request the page does not advance and the error is returned.
162func (page *ChangeListPage) NextWithContext(ctx context.Context) (err error) {
163	if tracing.IsEnabled() {
164		ctx = tracing.StartSpan(ctx, fqdn+"/ChangeListPage.NextWithContext")
165		defer func() {
166			sc := -1
167			if page.Response().Response.Response != nil {
168				sc = page.Response().Response.Response.StatusCode
169			}
170			tracing.EndSpan(ctx, sc, err)
171		}()
172	}
173	for {
174		next, err := page.fn(ctx, page.cl)
175		if err != nil {
176			return err
177		}
178		page.cl = next
179		if !next.hasNextLink() || !next.IsEmpty() {
180			break
181		}
182	}
183	return nil
184}
185
186// Next advances to the next page of values.  If there was an error making
187// the request the page does not advance and the error is returned.
188// Deprecated: Use NextWithContext() instead.
189func (page *ChangeListPage) Next() error {
190	return page.NextWithContext(context.Background())
191}
192
193// NotDone returns true if the page enumeration should be started or is not yet complete.
194func (page ChangeListPage) NotDone() bool {
195	return !page.cl.IsEmpty()
196}
197
198// Response returns the raw server response from the last page request.
199func (page ChangeListPage) Response() ChangeList {
200	return page.cl
201}
202
203// Values returns the slice of values for the current page or nil if there are no values.
204func (page ChangeListPage) Values() []Change {
205	if page.cl.IsEmpty() {
206		return nil
207	}
208	return *page.cl.Value
209}
210
211// Creates a new instance of the ChangeListPage type.
212func NewChangeListPage(cur ChangeList, getNextPage func(context.Context, ChangeList) (ChangeList, error)) ChangeListPage {
213	return ChangeListPage{
214		fn: getNextPage,
215		cl: cur,
216	}
217}
218
219// ChangeProperties the properties of a change.
220type ChangeProperties struct {
221	// ResourceID - The resource id that the change is attached to.
222	ResourceID *string `json:"resourceId,omitempty"`
223	// TimeStamp - The time when the change is detected.
224	TimeStamp *date.Time `json:"timeStamp,omitempty"`
225	// InitiatedByList - The list of identities who might initiated the change.
226	// The identity could be user name (email address) or the object ID of the Service Principal.
227	InitiatedByList *[]string `json:"initiatedByList,omitempty"`
228	// ChangeType - Possible values include: 'Add', 'Remove', 'Update'
229	ChangeType ChangeType `json:"changeType,omitempty"`
230	// PropertyChanges - The list of detailed changes at json property level.
231	PropertyChanges *[]PropertyChange `json:"propertyChanges,omitempty"`
232}
233
234// ErrorAdditionalInfo the resource management error additional info.
235type ErrorAdditionalInfo struct {
236	// Type - READ-ONLY; The additional info type.
237	Type *string `json:"type,omitempty"`
238	// Info - READ-ONLY; The additional info.
239	Info interface{} `json:"info,omitempty"`
240}
241
242// MarshalJSON is the custom marshaler for ErrorAdditionalInfo.
243func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) {
244	objectMap := make(map[string]interface{})
245	return json.Marshal(objectMap)
246}
247
248// ErrorDetail the error detail.
249type ErrorDetail struct {
250	// Code - READ-ONLY; The error code.
251	Code *string `json:"code,omitempty"`
252	// Message - READ-ONLY; The error message.
253	Message *string `json:"message,omitempty"`
254	// Target - READ-ONLY; The error target.
255	Target *string `json:"target,omitempty"`
256	// Details - READ-ONLY; The error details.
257	Details *[]ErrorDetail `json:"details,omitempty"`
258	// AdditionalInfo - READ-ONLY; The error additional info.
259	AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"`
260}
261
262// MarshalJSON is the custom marshaler for ErrorDetail.
263func (ed ErrorDetail) MarshalJSON() ([]byte, error) {
264	objectMap := make(map[string]interface{})
265	return json.Marshal(objectMap)
266}
267
268// ErrorResponse common error response for all Azure Resource Manager APIs to return error details for
269// failed operations. (This also follows the OData error response format.).
270type ErrorResponse struct {
271	// Error - The error object.
272	Error *ErrorDetail `json:"error,omitempty"`
273}
274
275// PropertyChange data of a property change.
276type PropertyChange struct {
277	// ChangeType - Possible values include: 'Add', 'Remove', 'Update'
278	ChangeType ChangeType `json:"changeType,omitempty"`
279	// ChangeCategory - The change category. Possible values include: 'User', 'System'
280	ChangeCategory ChangeCategory `json:"changeCategory,omitempty"`
281	// JSONPath - The json path of the changed property.
282	JSONPath *string `json:"jsonPath,omitempty"`
283	// DisplayName - The enhanced display name of the json path. E.g., the json path value[0].properties will be translated to something meaningful like slots["Staging"].properties.
284	DisplayName *string `json:"displayName,omitempty"`
285	// Level - Possible values include: 'Noisy', 'Normal', 'Important'
286	Level Level `json:"level,omitempty"`
287	// Description - The description of the changed property.
288	Description *string `json:"description,omitempty"`
289	// OldValue - The value of the property before the change.
290	OldValue *string `json:"oldValue,omitempty"`
291	// NewValue - The value of the property after the change.
292	NewValue *string `json:"newValue,omitempty"`
293	// IsDataMasked - The boolean indicating whether the oldValue and newValue are masked. The values are masked if it contains sensitive information that the user doesn't have access to.
294	IsDataMasked *bool `json:"isDataMasked,omitempty"`
295}
296
297// ProxyResource the resource model definition for a Azure Resource Manager proxy resource. It will not
298// have tags and a location
299type ProxyResource struct {
300	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
301	ID *string `json:"id,omitempty"`
302	// Name - READ-ONLY; The name of the resource
303	Name *string `json:"name,omitempty"`
304	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
305	Type *string `json:"type,omitempty"`
306}
307
308// MarshalJSON is the custom marshaler for ProxyResource.
309func (pr ProxyResource) MarshalJSON() ([]byte, error) {
310	objectMap := make(map[string]interface{})
311	return json.Marshal(objectMap)
312}
313
314// Resource common fields that are returned in the response for all Azure Resource Manager resources
315type Resource struct {
316	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
317	ID *string `json:"id,omitempty"`
318	// Name - READ-ONLY; The name of the resource
319	Name *string `json:"name,omitempty"`
320	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
321	Type *string `json:"type,omitempty"`
322}
323
324// MarshalJSON is the custom marshaler for Resource.
325func (r Resource) MarshalJSON() ([]byte, error) {
326	objectMap := make(map[string]interface{})
327	return json.Marshal(objectMap)
328}
329
330// ResourceProviderOperationDefinition the resource provider operation definition.
331type ResourceProviderOperationDefinition struct {
332	// Name - The resource provider operation name.
333	Name    *string                           `json:"name,omitempty"`
334	Display *ResourceProviderOperationDisplay `json:"display,omitempty"`
335}
336
337// ResourceProviderOperationDisplay the resource provider operation details.
338type ResourceProviderOperationDisplay struct {
339	// Provider - Name of the resource provider.
340	Provider *string `json:"provider,omitempty"`
341	// Resource - Name of the resource type.
342	Resource *string `json:"resource,omitempty"`
343	// Operation - Name of the resource provider operation.
344	Operation *string `json:"operation,omitempty"`
345	// Description - Description of the resource provider operation.
346	Description *string `json:"description,omitempty"`
347}
348
349// ResourceProviderOperationList the resource provider operation list.
350type ResourceProviderOperationList struct {
351	autorest.Response `json:"-"`
352	// Value - Resource provider operations list.
353	Value *[]ResourceProviderOperationDefinition `json:"value,omitempty"`
354	// NextLink - The URI that can be used to request the next page for list of Azure operations.
355	NextLink *string `json:"nextLink,omitempty"`
356}
357
358// ResourceProviderOperationListIterator provides access to a complete listing of
359// ResourceProviderOperationDefinition values.
360type ResourceProviderOperationListIterator struct {
361	i    int
362	page ResourceProviderOperationListPage
363}
364
365// NextWithContext advances to the next value.  If there was an error making
366// the request the iterator does not advance and the error is returned.
367func (iter *ResourceProviderOperationListIterator) NextWithContext(ctx context.Context) (err error) {
368	if tracing.IsEnabled() {
369		ctx = tracing.StartSpan(ctx, fqdn+"/ResourceProviderOperationListIterator.NextWithContext")
370		defer func() {
371			sc := -1
372			if iter.Response().Response.Response != nil {
373				sc = iter.Response().Response.Response.StatusCode
374			}
375			tracing.EndSpan(ctx, sc, err)
376		}()
377	}
378	iter.i++
379	if iter.i < len(iter.page.Values()) {
380		return nil
381	}
382	err = iter.page.NextWithContext(ctx)
383	if err != nil {
384		iter.i--
385		return err
386	}
387	iter.i = 0
388	return nil
389}
390
391// Next advances to the next value.  If there was an error making
392// the request the iterator does not advance and the error is returned.
393// Deprecated: Use NextWithContext() instead.
394func (iter *ResourceProviderOperationListIterator) Next() error {
395	return iter.NextWithContext(context.Background())
396}
397
398// NotDone returns true if the enumeration should be started or is not yet complete.
399func (iter ResourceProviderOperationListIterator) NotDone() bool {
400	return iter.page.NotDone() && iter.i < len(iter.page.Values())
401}
402
403// Response returns the raw server response from the last page request.
404func (iter ResourceProviderOperationListIterator) Response() ResourceProviderOperationList {
405	return iter.page.Response()
406}
407
408// Value returns the current value or a zero-initialized value if the
409// iterator has advanced beyond the end of the collection.
410func (iter ResourceProviderOperationListIterator) Value() ResourceProviderOperationDefinition {
411	if !iter.page.NotDone() {
412		return ResourceProviderOperationDefinition{}
413	}
414	return iter.page.Values()[iter.i]
415}
416
417// Creates a new instance of the ResourceProviderOperationListIterator type.
418func NewResourceProviderOperationListIterator(page ResourceProviderOperationListPage) ResourceProviderOperationListIterator {
419	return ResourceProviderOperationListIterator{page: page}
420}
421
422// IsEmpty returns true if the ListResult contains no values.
423func (rpol ResourceProviderOperationList) IsEmpty() bool {
424	return rpol.Value == nil || len(*rpol.Value) == 0
425}
426
427// hasNextLink returns true if the NextLink is not empty.
428func (rpol ResourceProviderOperationList) hasNextLink() bool {
429	return rpol.NextLink != nil && len(*rpol.NextLink) != 0
430}
431
432// resourceProviderOperationListPreparer prepares a request to retrieve the next set of results.
433// It returns nil if no more results exist.
434func (rpol ResourceProviderOperationList) resourceProviderOperationListPreparer(ctx context.Context) (*http.Request, error) {
435	if !rpol.hasNextLink() {
436		return nil, nil
437	}
438	return autorest.Prepare((&http.Request{}).WithContext(ctx),
439		autorest.AsJSON(),
440		autorest.AsGet(),
441		autorest.WithBaseURL(to.String(rpol.NextLink)))
442}
443
444// ResourceProviderOperationListPage contains a page of ResourceProviderOperationDefinition values.
445type ResourceProviderOperationListPage struct {
446	fn   func(context.Context, ResourceProviderOperationList) (ResourceProviderOperationList, error)
447	rpol ResourceProviderOperationList
448}
449
450// NextWithContext advances to the next page of values.  If there was an error making
451// the request the page does not advance and the error is returned.
452func (page *ResourceProviderOperationListPage) NextWithContext(ctx context.Context) (err error) {
453	if tracing.IsEnabled() {
454		ctx = tracing.StartSpan(ctx, fqdn+"/ResourceProviderOperationListPage.NextWithContext")
455		defer func() {
456			sc := -1
457			if page.Response().Response.Response != nil {
458				sc = page.Response().Response.Response.StatusCode
459			}
460			tracing.EndSpan(ctx, sc, err)
461		}()
462	}
463	for {
464		next, err := page.fn(ctx, page.rpol)
465		if err != nil {
466			return err
467		}
468		page.rpol = next
469		if !next.hasNextLink() || !next.IsEmpty() {
470			break
471		}
472	}
473	return nil
474}
475
476// Next advances to the next page of values.  If there was an error making
477// the request the page does not advance and the error is returned.
478// Deprecated: Use NextWithContext() instead.
479func (page *ResourceProviderOperationListPage) Next() error {
480	return page.NextWithContext(context.Background())
481}
482
483// NotDone returns true if the page enumeration should be started or is not yet complete.
484func (page ResourceProviderOperationListPage) NotDone() bool {
485	return !page.rpol.IsEmpty()
486}
487
488// Response returns the raw server response from the last page request.
489func (page ResourceProviderOperationListPage) Response() ResourceProviderOperationList {
490	return page.rpol
491}
492
493// Values returns the slice of values for the current page or nil if there are no values.
494func (page ResourceProviderOperationListPage) Values() []ResourceProviderOperationDefinition {
495	if page.rpol.IsEmpty() {
496		return nil
497	}
498	return *page.rpol.Value
499}
500
501// Creates a new instance of the ResourceProviderOperationListPage type.
502func NewResourceProviderOperationListPage(cur ResourceProviderOperationList, getNextPage func(context.Context, ResourceProviderOperationList) (ResourceProviderOperationList, error)) ResourceProviderOperationListPage {
503	return ResourceProviderOperationListPage{
504		fn:   getNextPage,
505		rpol: cur,
506	}
507}
508
509// TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource
510// which has 'tags' and a 'location'
511type TrackedResource struct {
512	// Tags - Resource tags.
513	Tags map[string]*string `json:"tags"`
514	// Location - The geo-location where the resource lives
515	Location *string `json:"location,omitempty"`
516	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
517	ID *string `json:"id,omitempty"`
518	// Name - READ-ONLY; The name of the resource
519	Name *string `json:"name,omitempty"`
520	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
521	Type *string `json:"type,omitempty"`
522}
523
524// MarshalJSON is the custom marshaler for TrackedResource.
525func (tr TrackedResource) MarshalJSON() ([]byte, error) {
526	objectMap := make(map[string]interface{})
527	if tr.Tags != nil {
528		objectMap["tags"] = tr.Tags
529	}
530	if tr.Location != nil {
531		objectMap["location"] = tr.Location
532	}
533	return json.Marshal(objectMap)
534}
535