From c840d8c09e4f4346a7e1d48a1b0d239eacd0ce77 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 25 Mar 2021 04:01:59 +0000 Subject: [PATCH] CodeGen from PR 13620 in Azure/azure-rest-api-specs add go sdk config (#13620) --- .../2021-04-01/changeanalysis/CHANGELOG.md | 5 + .../changeanalysisapi/interfaces.go | 50 ++ .../mgmt/2021-04-01/changeanalysis/changes.go | 310 +++++++++++ .../mgmt/2021-04-01/changeanalysis/client.go | 52 ++ .../mgmt/2021-04-01/changeanalysis/enums.go | 67 +++ .../mgmt/2021-04-01/changeanalysis/models.go | 515 ++++++++++++++++++ .../2021-04-01/changeanalysis/operations.go | 158 ++++++ .../changeanalysis/resourcechanges.go | 168 ++++++ .../mgmt/2021-04-01/changeanalysis/version.go | 30 + 9 files changed, 1355 insertions(+) create mode 100644 services/changeanalysis/mgmt/2021-04-01/changeanalysis/CHANGELOG.md create mode 100644 services/changeanalysis/mgmt/2021-04-01/changeanalysis/changeanalysisapi/interfaces.go create mode 100644 services/changeanalysis/mgmt/2021-04-01/changeanalysis/changes.go create mode 100644 services/changeanalysis/mgmt/2021-04-01/changeanalysis/client.go create mode 100644 services/changeanalysis/mgmt/2021-04-01/changeanalysis/enums.go create mode 100644 services/changeanalysis/mgmt/2021-04-01/changeanalysis/models.go create mode 100644 services/changeanalysis/mgmt/2021-04-01/changeanalysis/operations.go create mode 100644 services/changeanalysis/mgmt/2021-04-01/changeanalysis/resourcechanges.go create mode 100644 services/changeanalysis/mgmt/2021-04-01/changeanalysis/version.go diff --git a/services/changeanalysis/mgmt/2021-04-01/changeanalysis/CHANGELOG.md b/services/changeanalysis/mgmt/2021-04-01/changeanalysis/CHANGELOG.md new file mode 100644 index 000000000000..1380aa9e4d68 --- /dev/null +++ b/services/changeanalysis/mgmt/2021-04-01/changeanalysis/CHANGELOG.md @@ -0,0 +1,5 @@ +Generated from https://github.com/Azure/azure-rest-api-specs/tree/0f0e41fa4e3679510fcf03ecd60084f1cdbd5805/specification/changeanalysis/resource-manager/readme.md tag: `package-2021-04-01` + +Code generator + + diff --git a/services/changeanalysis/mgmt/2021-04-01/changeanalysis/changeanalysisapi/interfaces.go b/services/changeanalysis/mgmt/2021-04-01/changeanalysis/changeanalysisapi/interfaces.go new file mode 100644 index 000000000000..d5577381494b --- /dev/null +++ b/services/changeanalysis/mgmt/2021-04-01/changeanalysis/changeanalysisapi/interfaces.go @@ -0,0 +1,50 @@ +package changeanalysisapi + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/changeanalysis/mgmt/2021-04-01/changeanalysis" + "github.com/Azure/go-autorest/autorest/date" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context, skipToken string) (result changeanalysis.ResourceProviderOperationListPage, err error) + ListComplete(ctx context.Context, skipToken string) (result changeanalysis.ResourceProviderOperationListIterator, err error) +} + +var _ OperationsClientAPI = (*changeanalysis.OperationsClient)(nil) + +// ResourceChangesClientAPI contains the set of methods on the ResourceChangesClient type. +type ResourceChangesClientAPI interface { + List(ctx context.Context, resourceID string, startTime date.Time, endTime date.Time, skipToken string) (result changeanalysis.ChangeListPage, err error) + ListComplete(ctx context.Context, resourceID string, startTime date.Time, endTime date.Time, skipToken string) (result changeanalysis.ChangeListIterator, err error) +} + +var _ ResourceChangesClientAPI = (*changeanalysis.ResourceChangesClient)(nil) + +// ChangesClientAPI contains the set of methods on the ChangesClient type. +type ChangesClientAPI interface { + ListChangesByResourceGroup(ctx context.Context, resourceGroupName string, startTime date.Time, endTime date.Time, skipToken string) (result changeanalysis.ChangeListPage, err error) + ListChangesByResourceGroupComplete(ctx context.Context, resourceGroupName string, startTime date.Time, endTime date.Time, skipToken string) (result changeanalysis.ChangeListIterator, err error) + ListChangesBySubscription(ctx context.Context, startTime date.Time, endTime date.Time, skipToken string) (result changeanalysis.ChangeListPage, err error) + ListChangesBySubscriptionComplete(ctx context.Context, startTime date.Time, endTime date.Time, skipToken string) (result changeanalysis.ChangeListIterator, err error) +} + +var _ ChangesClientAPI = (*changeanalysis.ChangesClient)(nil) diff --git a/services/changeanalysis/mgmt/2021-04-01/changeanalysis/changes.go b/services/changeanalysis/mgmt/2021-04-01/changeanalysis/changes.go new file mode 100644 index 000000000000..967d97c9f7b2 --- /dev/null +++ b/services/changeanalysis/mgmt/2021-04-01/changeanalysis/changes.go @@ -0,0 +1,310 @@ +package changeanalysis + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ChangesClient is the client for the Changes methods of the Changeanalysis service. +type ChangesClient struct { + BaseClient +} + +// NewChangesClient creates an instance of the ChangesClient client. +func NewChangesClient(subscriptionID string) ChangesClient { + return NewChangesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewChangesClientWithBaseURI creates an instance of the ChangesClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewChangesClientWithBaseURI(baseURI string, subscriptionID string) ChangesClient { + return ChangesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListChangesByResourceGroup sends the list changes by resource group request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// startTime - specifies the start time of the changes request. +// endTime - specifies the end time of the changes request. +// skipToken - a skip token is used to continue retrieving items after an operation returns a partial result. +// If a previous response contains a nextLink element, the value of the nextLink element will include a +// skipToken parameter that specifies a starting point to use for subsequent calls. +func (client ChangesClient) ListChangesByResourceGroup(ctx context.Context, resourceGroupName string, startTime date.Time, endTime date.Time, skipToken string) (result ChangeListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ChangesClient.ListChangesByResourceGroup") + defer func() { + sc := -1 + if result.cl.Response.Response != nil { + sc = result.cl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("changeanalysis.ChangesClient", "ListChangesByResourceGroup", err.Error()) + } + + result.fn = client.listChangesByResourceGroupNextResults + req, err := client.ListChangesByResourceGroupPreparer(ctx, resourceGroupName, startTime, endTime, skipToken) + if err != nil { + err = autorest.NewErrorWithError(err, "changeanalysis.ChangesClient", "ListChangesByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListChangesByResourceGroupSender(req) + if err != nil { + result.cl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "changeanalysis.ChangesClient", "ListChangesByResourceGroup", resp, "Failure sending request") + return + } + + result.cl, err = client.ListChangesByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "changeanalysis.ChangesClient", "ListChangesByResourceGroup", resp, "Failure responding to request") + return + } + if result.cl.hasNextLink() && result.cl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListChangesByResourceGroupPreparer prepares the ListChangesByResourceGroup request. +func (client ChangesClient) ListChangesByResourceGroupPreparer(ctx context.Context, resourceGroupName string, startTime date.Time, endTime date.Time, skipToken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "$endTime": autorest.Encode("query", endTime), + "$startTime": autorest.Encode("query", startTime), + "api-version": APIVersion, + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ChangeAnalysis/changes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListChangesByResourceGroupSender sends the ListChangesByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ChangesClient) ListChangesByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListChangesByResourceGroupResponder handles the response to the ListChangesByResourceGroup request. The method always +// closes the http.Response Body. +func (client ChangesClient) ListChangesByResourceGroupResponder(resp *http.Response) (result ChangeList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listChangesByResourceGroupNextResults retrieves the next set of results, if any. +func (client ChangesClient) listChangesByResourceGroupNextResults(ctx context.Context, lastResults ChangeList) (result ChangeList, err error) { + req, err := lastResults.changeListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "changeanalysis.ChangesClient", "listChangesByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListChangesByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "changeanalysis.ChangesClient", "listChangesByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListChangesByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "changeanalysis.ChangesClient", "listChangesByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListChangesByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ChangesClient) ListChangesByResourceGroupComplete(ctx context.Context, resourceGroupName string, startTime date.Time, endTime date.Time, skipToken string) (result ChangeListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ChangesClient.ListChangesByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListChangesByResourceGroup(ctx, resourceGroupName, startTime, endTime, skipToken) + return +} + +// ListChangesBySubscription sends the list changes by subscription request. +// Parameters: +// startTime - specifies the start time of the changes request. +// endTime - specifies the end time of the changes request. +// skipToken - a skip token is used to continue retrieving items after an operation returns a partial result. +// If a previous response contains a nextLink element, the value of the nextLink element will include a +// skipToken parameter that specifies a starting point to use for subsequent calls. +func (client ChangesClient) ListChangesBySubscription(ctx context.Context, startTime date.Time, endTime date.Time, skipToken string) (result ChangeListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ChangesClient.ListChangesBySubscription") + defer func() { + sc := -1 + if result.cl.Response.Response != nil { + sc = result.cl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("changeanalysis.ChangesClient", "ListChangesBySubscription", err.Error()) + } + + result.fn = client.listChangesBySubscriptionNextResults + req, err := client.ListChangesBySubscriptionPreparer(ctx, startTime, endTime, skipToken) + if err != nil { + err = autorest.NewErrorWithError(err, "changeanalysis.ChangesClient", "ListChangesBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListChangesBySubscriptionSender(req) + if err != nil { + result.cl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "changeanalysis.ChangesClient", "ListChangesBySubscription", resp, "Failure sending request") + return + } + + result.cl, err = client.ListChangesBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "changeanalysis.ChangesClient", "ListChangesBySubscription", resp, "Failure responding to request") + return + } + if result.cl.hasNextLink() && result.cl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListChangesBySubscriptionPreparer prepares the ListChangesBySubscription request. +func (client ChangesClient) ListChangesBySubscriptionPreparer(ctx context.Context, startTime date.Time, endTime date.Time, skipToken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "$endTime": autorest.Encode("query", endTime), + "$startTime": autorest.Encode("query", startTime), + "api-version": APIVersion, + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ChangeAnalysis/changes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListChangesBySubscriptionSender sends the ListChangesBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client ChangesClient) ListChangesBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListChangesBySubscriptionResponder handles the response to the ListChangesBySubscription request. The method always +// closes the http.Response Body. +func (client ChangesClient) ListChangesBySubscriptionResponder(resp *http.Response) (result ChangeList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listChangesBySubscriptionNextResults retrieves the next set of results, if any. +func (client ChangesClient) listChangesBySubscriptionNextResults(ctx context.Context, lastResults ChangeList) (result ChangeList, err error) { + req, err := lastResults.changeListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "changeanalysis.ChangesClient", "listChangesBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListChangesBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "changeanalysis.ChangesClient", "listChangesBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListChangesBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "changeanalysis.ChangesClient", "listChangesBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListChangesBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client ChangesClient) ListChangesBySubscriptionComplete(ctx context.Context, startTime date.Time, endTime date.Time, skipToken string) (result ChangeListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ChangesClient.ListChangesBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListChangesBySubscription(ctx, startTime, endTime, skipToken) + return +} diff --git a/services/changeanalysis/mgmt/2021-04-01/changeanalysis/client.go b/services/changeanalysis/mgmt/2021-04-01/changeanalysis/client.go new file mode 100644 index 000000000000..b57c5ad9ebbb --- /dev/null +++ b/services/changeanalysis/mgmt/2021-04-01/changeanalysis/client.go @@ -0,0 +1,52 @@ +// Package changeanalysis implements the Azure ARM Changeanalysis service API version 2021-04-01. +// +// +package changeanalysis + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Changeanalysis + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Changeanalysis. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/changeanalysis/mgmt/2021-04-01/changeanalysis/enums.go b/services/changeanalysis/mgmt/2021-04-01/changeanalysis/enums.go new file mode 100644 index 000000000000..d521e9a42422 --- /dev/null +++ b/services/changeanalysis/mgmt/2021-04-01/changeanalysis/enums.go @@ -0,0 +1,67 @@ +package changeanalysis + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// ChangeCategory enumerates the values for change category. +type ChangeCategory string + +const ( + // System ... + System ChangeCategory = "System" + // User ... + User ChangeCategory = "User" +) + +// PossibleChangeCategoryValues returns an array of possible values for the ChangeCategory const type. +func PossibleChangeCategoryValues() []ChangeCategory { + return []ChangeCategory{System, User} +} + +// ChangeType enumerates the values for change type. +type ChangeType string + +const ( + // Add ... + Add ChangeType = "Add" + // Remove ... + Remove ChangeType = "Remove" + // Update ... + Update ChangeType = "Update" +) + +// PossibleChangeTypeValues returns an array of possible values for the ChangeType const type. +func PossibleChangeTypeValues() []ChangeType { + return []ChangeType{Add, Remove, Update} +} + +// Level enumerates the values for level. +type Level string + +const ( + // Important ... + Important Level = "Important" + // Noisy ... + Noisy Level = "Noisy" + // Normal ... + Normal Level = "Normal" +) + +// PossibleLevelValues returns an array of possible values for the Level const type. +func PossibleLevelValues() []Level { + return []Level{Important, Noisy, Normal} +} diff --git a/services/changeanalysis/mgmt/2021-04-01/changeanalysis/models.go b/services/changeanalysis/mgmt/2021-04-01/changeanalysis/models.go new file mode 100644 index 000000000000..13fca0a04cc4 --- /dev/null +++ b/services/changeanalysis/mgmt/2021-04-01/changeanalysis/models.go @@ -0,0 +1,515 @@ +package changeanalysis + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/changeanalysis/mgmt/2021-04-01/changeanalysis" + +// AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag. +type AzureEntityResource struct { + // Etag - READ-ONLY; Resource Etag. + Etag *string `json:"etag,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// Change the detected change. +type Change struct { + Properties *ChangeProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Change. +func (c Change) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.Properties != nil { + objectMap["properties"] = c.Properties + } + return json.Marshal(objectMap) +} + +// ChangeList the list of detected changes. +type ChangeList struct { + autorest.Response `json:"-"` + // Value - The list of changes. + Value *[]Change `json:"value,omitempty"` + // NextLink - The URI that can be used to request the next page of changes. + NextLink *string `json:"nextLink,omitempty"` +} + +// ChangeListIterator provides access to a complete listing of Change values. +type ChangeListIterator struct { + i int + page ChangeListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ChangeListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ChangeListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ChangeListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ChangeListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ChangeListIterator) Response() ChangeList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ChangeListIterator) Value() Change { + if !iter.page.NotDone() { + return Change{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ChangeListIterator type. +func NewChangeListIterator(page ChangeListPage) ChangeListIterator { + return ChangeListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (cl ChangeList) IsEmpty() bool { + return cl.Value == nil || len(*cl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (cl ChangeList) hasNextLink() bool { + return cl.NextLink != nil && len(*cl.NextLink) != 0 +} + +// changeListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (cl ChangeList) changeListPreparer(ctx context.Context) (*http.Request, error) { + if !cl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(cl.NextLink))) +} + +// ChangeListPage contains a page of Change values. +type ChangeListPage struct { + fn func(context.Context, ChangeList) (ChangeList, error) + cl ChangeList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ChangeListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ChangeListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.cl) + if err != nil { + return err + } + page.cl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ChangeListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ChangeListPage) NotDone() bool { + return !page.cl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ChangeListPage) Response() ChangeList { + return page.cl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ChangeListPage) Values() []Change { + if page.cl.IsEmpty() { + return nil + } + return *page.cl.Value +} + +// Creates a new instance of the ChangeListPage type. +func NewChangeListPage(cur ChangeList, getNextPage func(context.Context, ChangeList) (ChangeList, error)) ChangeListPage { + return ChangeListPage{ + fn: getNextPage, + cl: cur, + } +} + +// ChangeProperties the properties of a change. +type ChangeProperties struct { + // ResourceID - The resource id that the change is attached to. + ResourceID *string `json:"resourceId,omitempty"` + // TimeStamp - The time when the change is detected. + TimeStamp *date.Time `json:"timeStamp,omitempty"` + // InitiatedByList - The list of identities who might initiated the change. + // The identity could be user name (email address) or the object ID of the Service Principal. + InitiatedByList *[]string `json:"initiatedByList,omitempty"` + // ChangeType - Possible values include: 'Add', 'Remove', 'Update' + ChangeType ChangeType `json:"changeType,omitempty"` + // PropertyChanges - The list of detailed changes at json property level. + PropertyChanges *[]PropertyChange `json:"propertyChanges,omitempty"` +} + +// ErrorAdditionalInfo the resource management error additional info. +type ErrorAdditionalInfo struct { + // Type - READ-ONLY; The additional info type. + Type *string `json:"type,omitempty"` + // Info - READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty"` +} + +// ErrorDetail the error detail. +type ErrorDetail struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The error target. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; The error details. + Details *[]ErrorDetail `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// ErrorResponse common error response for all Azure Resource Manager APIs to return error details for +// failed operations. (This also follows the OData error response format.). +type ErrorResponse struct { + // Error - The error object. + Error *ErrorDetail `json:"error,omitempty"` +} + +// PropertyChange data of a property change. +type PropertyChange struct { + // ChangeType - Possible values include: 'Add', 'Remove', 'Update' + ChangeType ChangeType `json:"changeType,omitempty"` + // ChangeCategory - The change category. Possible values include: 'User', 'System' + ChangeCategory ChangeCategory `json:"changeCategory,omitempty"` + // JSONPath - The json path of the changed property. + JSONPath *string `json:"jsonPath,omitempty"` + // 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. + DisplayName *string `json:"displayName,omitempty"` + // Level - Possible values include: 'Noisy', 'Normal', 'Important' + Level Level `json:"level,omitempty"` + // Description - The description of the changed property. + Description *string `json:"description,omitempty"` + // OldValue - The value of the property before the change. + OldValue *string `json:"oldValue,omitempty"` + // NewValue - The value of the property after the change. + NewValue *string `json:"newValue,omitempty"` + // 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. + IsDataMasked *bool `json:"isDataMasked,omitempty"` +} + +// ProxyResource the resource model definition for a Azure Resource Manager proxy resource. It will not +// have tags and a location +type ProxyResource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// Resource common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// ResourceProviderOperationDefinition the resource provider operation definition. +type ResourceProviderOperationDefinition struct { + // Name - The resource provider operation name. + Name *string `json:"name,omitempty"` + Display *ResourceProviderOperationDisplay `json:"display,omitempty"` +} + +// ResourceProviderOperationDisplay the resource provider operation details. +type ResourceProviderOperationDisplay struct { + // Provider - Name of the resource provider. + Provider *string `json:"provider,omitempty"` + // Resource - Name of the resource type. + Resource *string `json:"resource,omitempty"` + // Operation - Name of the resource provider operation. + Operation *string `json:"operation,omitempty"` + // Description - Description of the resource provider operation. + Description *string `json:"description,omitempty"` +} + +// ResourceProviderOperationList the resource provider operation list. +type ResourceProviderOperationList struct { + autorest.Response `json:"-"` + // Value - Resource provider operations list. + Value *[]ResourceProviderOperationDefinition `json:"value,omitempty"` + // NextLink - The URI that can be used to request the next page for list of Azure operations. + NextLink *string `json:"nextLink,omitempty"` +} + +// ResourceProviderOperationListIterator provides access to a complete listing of +// ResourceProviderOperationDefinition values. +type ResourceProviderOperationListIterator struct { + i int + page ResourceProviderOperationListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ResourceProviderOperationListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceProviderOperationListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ResourceProviderOperationListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ResourceProviderOperationListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ResourceProviderOperationListIterator) Response() ResourceProviderOperationList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ResourceProviderOperationListIterator) Value() ResourceProviderOperationDefinition { + if !iter.page.NotDone() { + return ResourceProviderOperationDefinition{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ResourceProviderOperationListIterator type. +func NewResourceProviderOperationListIterator(page ResourceProviderOperationListPage) ResourceProviderOperationListIterator { + return ResourceProviderOperationListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rpol ResourceProviderOperationList) IsEmpty() bool { + return rpol.Value == nil || len(*rpol.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rpol ResourceProviderOperationList) hasNextLink() bool { + return rpol.NextLink != nil && len(*rpol.NextLink) != 0 +} + +// resourceProviderOperationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rpol ResourceProviderOperationList) resourceProviderOperationListPreparer(ctx context.Context) (*http.Request, error) { + if !rpol.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rpol.NextLink))) +} + +// ResourceProviderOperationListPage contains a page of ResourceProviderOperationDefinition values. +type ResourceProviderOperationListPage struct { + fn func(context.Context, ResourceProviderOperationList) (ResourceProviderOperationList, error) + rpol ResourceProviderOperationList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ResourceProviderOperationListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceProviderOperationListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rpol) + if err != nil { + return err + } + page.rpol = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ResourceProviderOperationListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ResourceProviderOperationListPage) NotDone() bool { + return !page.rpol.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ResourceProviderOperationListPage) Response() ResourceProviderOperationList { + return page.rpol +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ResourceProviderOperationListPage) Values() []ResourceProviderOperationDefinition { + if page.rpol.IsEmpty() { + return nil + } + return *page.rpol.Value +} + +// Creates a new instance of the ResourceProviderOperationListPage type. +func NewResourceProviderOperationListPage(cur ResourceProviderOperationList, getNextPage func(context.Context, ResourceProviderOperationList) (ResourceProviderOperationList, error)) ResourceProviderOperationListPage { + return ResourceProviderOperationListPage{ + fn: getNextPage, + rpol: cur, + } +} + +// TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource +// which has 'tags' and a 'location' +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + return json.Marshal(objectMap) +} diff --git a/services/changeanalysis/mgmt/2021-04-01/changeanalysis/operations.go b/services/changeanalysis/mgmt/2021-04-01/changeanalysis/operations.go new file mode 100644 index 000000000000..b2a059be3040 --- /dev/null +++ b/services/changeanalysis/mgmt/2021-04-01/changeanalysis/operations.go @@ -0,0 +1,158 @@ +package changeanalysis + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the client for the Operations methods of the Changeanalysis service. +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List sends the list request. +// Parameters: +// skipToken - a skip token is used to continue retrieving items after an operation returns a partial result. +// If a previous response contains a nextLink element, the value of the nextLink element will include a +// skipToken parameter that specifies a starting point to use for subsequent calls. +func (client OperationsClient) List(ctx context.Context, skipToken string) (result ResourceProviderOperationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.rpol.Response.Response != nil { + sc = result.rpol.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, skipToken) + if err != nil { + err = autorest.NewErrorWithError(err, "changeanalysis.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.rpol.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "changeanalysis.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.rpol, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "changeanalysis.OperationsClient", "List", resp, "Failure responding to request") + return + } + if result.rpol.hasNextLink() && result.rpol.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context, skipToken string) (*http.Request, error) { + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.ChangeAnalysis/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result ResourceProviderOperationList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults ResourceProviderOperationList) (result ResourceProviderOperationList, err error) { + req, err := lastResults.resourceProviderOperationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "changeanalysis.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "changeanalysis.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "changeanalysis.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context, skipToken string) (result ResourceProviderOperationListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, skipToken) + return +} diff --git a/services/changeanalysis/mgmt/2021-04-01/changeanalysis/resourcechanges.go b/services/changeanalysis/mgmt/2021-04-01/changeanalysis/resourcechanges.go new file mode 100644 index 000000000000..87db7a6a69ae --- /dev/null +++ b/services/changeanalysis/mgmt/2021-04-01/changeanalysis/resourcechanges.go @@ -0,0 +1,168 @@ +package changeanalysis + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ResourceChangesClient is the client for the ResourceChanges methods of the Changeanalysis service. +type ResourceChangesClient struct { + BaseClient +} + +// NewResourceChangesClient creates an instance of the ResourceChangesClient client. +func NewResourceChangesClient(subscriptionID string) ResourceChangesClient { + return NewResourceChangesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewResourceChangesClientWithBaseURI creates an instance of the ResourceChangesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewResourceChangesClientWithBaseURI(baseURI string, subscriptionID string) ResourceChangesClient { + return ResourceChangesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List sends the list request. +// Parameters: +// resourceID - the identifier of the resource. +// startTime - specifies the start time of the changes request. +// endTime - specifies the end time of the changes request. +// skipToken - a skip token is used to continue retrieving items after an operation returns a partial result. +// If a previous response contains a nextLink element, the value of the nextLink element will include a +// skipToken parameter that specifies a starting point to use for subsequent calls. +func (client ResourceChangesClient) List(ctx context.Context, resourceID string, startTime date.Time, endTime date.Time, skipToken string) (result ChangeListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceChangesClient.List") + defer func() { + sc := -1 + if result.cl.Response.Response != nil { + sc = result.cl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceID, startTime, endTime, skipToken) + if err != nil { + err = autorest.NewErrorWithError(err, "changeanalysis.ResourceChangesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.cl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "changeanalysis.ResourceChangesClient", "List", resp, "Failure sending request") + return + } + + result.cl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "changeanalysis.ResourceChangesClient", "List", resp, "Failure responding to request") + return + } + if result.cl.hasNextLink() && result.cl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ResourceChangesClient) ListPreparer(ctx context.Context, resourceID string, startTime date.Time, endTime date.Time, skipToken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceId": autorest.Encode("path", resourceID), + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "$endTime": autorest.Encode("query", endTime), + "$startTime": autorest.Encode("query", startTime), + "api-version": APIVersion, + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.ChangeAnalysis/resourceChanges", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ResourceChangesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ResourceChangesClient) ListResponder(resp *http.Response) (result ChangeList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ResourceChangesClient) listNextResults(ctx context.Context, lastResults ChangeList) (result ChangeList, err error) { + req, err := lastResults.changeListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "changeanalysis.ResourceChangesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "changeanalysis.ResourceChangesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "changeanalysis.ResourceChangesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ResourceChangesClient) ListComplete(ctx context.Context, resourceID string, startTime date.Time, endTime date.Time, skipToken string) (result ChangeListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceChangesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceID, startTime, endTime, skipToken) + return +} diff --git a/services/changeanalysis/mgmt/2021-04-01/changeanalysis/version.go b/services/changeanalysis/mgmt/2021-04-01/changeanalysis/version.go new file mode 100644 index 000000000000..64c5aca0b939 --- /dev/null +++ b/services/changeanalysis/mgmt/2021-04-01/changeanalysis/version.go @@ -0,0 +1,30 @@ +package changeanalysis + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " changeanalysis/2021-04-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}