diff --git a/internal/services/resource/client/client.go b/internal/services/resource/client/client.go index 73e0742446a2..737a2e634fd0 100644 --- a/internal/services/resource/client/client.go +++ b/internal/services/resource/client/client.go @@ -4,8 +4,8 @@ import ( providers "github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources" "github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2019-06-01-preview/templatespecs" // nolint: staticcheck "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2015-12-01/features" // nolint: staticcheck - "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks" // nolint: staticcheck "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-06-01/resources" // nolint: staticcheck + "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks" "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-10-01/deploymentscripts" "github.com/hashicorp/terraform-provider-azurerm/internal/common" ) @@ -15,7 +15,7 @@ type Client struct { DeploymentScriptsClient *deploymentscripts.DeploymentScriptsClient FeaturesClient *features.Client GroupsClient *resources.GroupsClient - LocksClient *locks.ManagementLocksClient + LocksClient *managementlocks.ManagementLocksClient ProvidersClient *providers.ProvidersClient ResourceProvidersClient *resources.ProvidersClient ResourcesClient *resources.Client @@ -38,7 +38,7 @@ func NewClient(o *common.ClientOptions) *Client { groupsClient := resources.NewGroupsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&groupsClient.Client, o.ResourceManagerAuthorizer) - locksClient := locks.NewManagementLocksClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + locksClient := managementlocks.NewManagementLocksClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&locksClient.Client, o.ResourceManagerAuthorizer) // this has to come from the Profile since this is shared with Stack diff --git a/internal/services/resource/management_lock_resource.go b/internal/services/resource/management_lock_resource.go index 7273fd7d37c6..737cb6f0788b 100644 --- a/internal/services/resource/management_lock_resource.go +++ b/internal/services/resource/management_lock_resource.go @@ -2,13 +2,12 @@ package resource import ( "fmt" - "log" "time" - "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/resource/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/resource/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -18,12 +17,12 @@ import ( func resourceManagementLock() *pluginsdk.Resource { return &pluginsdk.Resource{ - Create: resourceManagementLockCreateUpdate, + Create: resourceManagementLockCreate, Read: resourceManagementLockRead, Delete: resourceManagementLockDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.ParseManagementLockID(id) + _, err := managementlocks.ParseScopedLockID(id) return err }), @@ -53,8 +52,8 @@ func resourceManagementLock() *pluginsdk.Resource { Required: true, ForceNew: true, ValidateFunc: validation.StringInSlice([]string{ - string(locks.CanNotDelete), - string(locks.ReadOnly), + string(managementlocks.LockLevelCanNotDelete), + string(managementlocks.LockLevelReadOnly), }, false), }, @@ -68,34 +67,33 @@ func resourceManagementLock() *pluginsdk.Resource { } } -func resourceManagementLockCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { +func resourceManagementLockCreate(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).Resource.LocksClient - ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - log.Printf("[INFO] preparing arguments for AzureRM Management Lock creation.") - id := parse.NewManagementLockID(d.Get("scope").(string), d.Get("name").(string)) + id := managementlocks.NewScopedLockID(d.Get("scope").(string), d.Get("name").(string)) if d.IsNewResource() { - existing, err := client.GetByScope(ctx, id.Scope, id.Name) + existing, err := client.GetByScope(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { + if !response.WasNotFound(existing.HttpResponse) { return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { + if !response.WasNotFound(existing.HttpResponse) { return tf.ImportAsExistsError("azurerm_management_lock", id.ID()) } } - lock := locks.ManagementLockObject{ - ManagementLockProperties: &locks.ManagementLockProperties{ - Level: locks.LockLevel(d.Get("lock_level").(string)), + payload := managementlocks.ManagementLockObject{ + Properties: managementlocks.ManagementLockProperties{ + Level: managementlocks.LockLevel(d.Get("lock_level").(string)), Notes: utils.String(d.Get("notes").(string)), }, } - if _, err := client.CreateOrUpdateByScope(ctx, id.Scope, id.Name, lock); err != nil { + if _, err := client.CreateOrUpdateByScope(ctx, id, payload); err != nil { return fmt.Errorf("creating %s: %+v", id, err) } @@ -108,14 +106,14 @@ func resourceManagementLockRead(d *pluginsdk.ResourceData, meta interface{}) err ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.ParseManagementLockID(d.Id()) + id, err := managementlocks.ParseScopedLockID(d.Id()) if err != nil { return err } - resp, err := client.GetByScope(ctx, id.Scope, id.Name) + resp, err := client.GetByScope(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } @@ -123,12 +121,12 @@ func resourceManagementLockRead(d *pluginsdk.ResourceData, meta interface{}) err return fmt.Errorf("retrieving %s: %+v", *id, err) } - d.Set("name", id.Name) + d.Set("name", id.LockName) d.Set("scope", id.Scope) - if props := resp.ManagementLockProperties; props != nil { - d.Set("lock_level", string(props.Level)) - d.Set("notes", props.Notes) + if model := resp.Model; model != nil { + d.Set("lock_level", string(model.Properties.Level)) + d.Set("notes", model.Properties.Notes) } return nil @@ -139,15 +137,15 @@ func resourceManagementLockDelete(d *pluginsdk.ResourceData, meta interface{}) e ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.ParseManagementLockID(d.Id()) + id, err := managementlocks.ParseScopedLockID(d.Id()) if err != nil { return err } - if resp, err := client.DeleteByScope(ctx, id.Scope, id.Name); err != nil { + if resp, err := client.DeleteByScope(ctx, *id); err != nil { // @tombuildsstuff: this is intentionally here in case the parent is gone, since we're under a scope - // which isn't ideal (as this shouldn't be present for most resources) but should for this one - if utils.ResponseWasNotFound(resp) { + // which isn't ideal (as this logic shouldn't be present for most resources) but should for this one + if response.WasNotFound(resp.HttpResponse) { return nil } diff --git a/internal/services/resource/management_lock_resource_test.go b/internal/services/resource/management_lock_resource_test.go index 96f55ab2ffee..a55b4577a3c7 100644 --- a/internal/services/resource/management_lock_resource_test.go +++ b/internal/services/resource/management_lock_resource_test.go @@ -6,10 +6,10 @@ import ( "os" "testing" + "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/resource/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -162,17 +162,17 @@ func TestAccManagementLock_subscriptionCanNotDeleteBasic(t *testing.T) { } func (t ManagementLockResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.ParseManagementLockID(state.ID) + id, err := managementlocks.ParseScopedLockID(state.ID) if err != nil { return nil, err } - resp, err := clients.Resource.LocksClient.GetByScope(ctx, id.Scope, id.Name) + resp, err := clients.Resource.LocksClient.GetByScope(ctx, *id) if err != nil { - return nil, fmt.Errorf("reading Management Lock (%s): %+v", id, err) + return nil, fmt.Errorf("reading %s: %+v", *id, err) } - return utils.Bool(resp.ID != nil), nil + return utils.Bool(resp.Model != nil), nil } func (ManagementLockResource) resourceGroupReadOnlyBasic(data acceptance.TestData) string { diff --git a/internal/services/resource/parse/management_lock.go b/internal/services/resource/parse/management_lock.go deleted file mode 100644 index 277ec8689cca..000000000000 --- a/internal/services/resource/parse/management_lock.go +++ /dev/null @@ -1,87 +0,0 @@ -package parse - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = ManagementLockId{} - -// ManagementLockId is a struct representing the Resource ID for a Management Lock -type ManagementLockId struct { - Scope string - Name string -} - -// NewManagementLockID returns a new ManagementLockId struct -func NewManagementLockID(scope string, name string) ManagementLockId { - return ManagementLockId{ - Scope: scope, - Name: name, - } -} - -// ParseManagementLockID parses 'input' into a ManagementLockId -func ParseManagementLockID(input string) (*ManagementLockId, error) { - parser := resourceids.NewParserFromResourceIdType(ManagementLockId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := ManagementLockId{} - - if id.Scope, ok = parsed.Parsed["scope"]; !ok { - return nil, fmt.Errorf("the segment 'scope' was not found in the resource id %q", input) - } - - if id.Name, ok = parsed.Parsed["lockName"]; !ok { - return nil, fmt.Errorf("the segment 'lockName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateManagementLockID checks that 'input' can be parsed as a Management Lock ID -func ValidateManagementLockID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseManagementLockID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Management Lock ID -func (id ManagementLockId) ID() string { - fmtString := "%s/providers/Microsoft.Authorization/locks/%s" - return fmt.Sprintf(fmtString, id.Scope, id.Name) -} - -// Segments returns a slice of Resource ID Segments which comprise this Management Lock ID -func (id ManagementLockId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.ScopeSegment("scope", "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group"), - resourceids.StaticSegment("providers", "providers", "providers"), - resourceids.ResourceProviderSegment("microsoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), - resourceids.StaticSegment("locks", "locks", "locks"), - resourceids.UserSpecifiedSegment("lockName", "lockValue"), - } -} - -// String returns a human-readable description of this Management Lock ID -func (id ManagementLockId) String() string { - components := []string{ - fmt.Sprintf("Scope: %q", id.Scope), - fmt.Sprintf("Name: %q", id.Name), - } - return fmt.Sprintf("Management Lock (%s)", strings.Join(components, "\n")) -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/CHANGELOG.md deleted file mode 100644 index 52911e4cc5e4..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/CHANGELOG.md +++ /dev/null @@ -1,2 +0,0 @@ -# Change History - diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/_meta.json b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/_meta.json deleted file mode 100644 index 961e9e652911..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/_meta.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", - "readme": "/_/azure-rest-api-specs/specification/resources/resource-manager/readme.md", - "tag": "package-locks-2016-09", - "use": "@microsoft.azure/autorest.go@2.1.187", - "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-locks-2016-09 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/resources/resource-manager/readme.md", - "additional_properties": { - "additional_options": "--go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION" - } -} \ No newline at end of file diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/authorizationoperations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/authorizationoperations.go deleted file mode 100644 index 01011a4e3e1f..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/authorizationoperations.go +++ /dev/null @@ -1,142 +0,0 @@ -package locks - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// 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" -) - -// AuthorizationOperationsClient is the azure resources can be locked to prevent other users in your organization from -// deleting or modifying resources. -type AuthorizationOperationsClient struct { - BaseClient -} - -// NewAuthorizationOperationsClient creates an instance of the AuthorizationOperationsClient client. -func NewAuthorizationOperationsClient(subscriptionID string) AuthorizationOperationsClient { - return NewAuthorizationOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewAuthorizationOperationsClientWithBaseURI creates an instance of the AuthorizationOperationsClient 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 NewAuthorizationOperationsClientWithBaseURI(baseURI string, subscriptionID string) AuthorizationOperationsClient { - return AuthorizationOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// List lists all of the available Microsoft.Authorization REST API operations. -func (client AuthorizationOperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationOperationsClient.List") - defer func() { - sc := -1 - if result.olr.Response.Response != nil { - sc = result.olr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.AuthorizationOperationsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.olr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "locks.AuthorizationOperationsClient", "List", resp, "Failure sending request") - return - } - - result.olr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.AuthorizationOperationsClient", "List", resp, "Failure responding to request") - return - } - if result.olr.hasNextLink() && result.olr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListPreparer prepares the List request. -func (client AuthorizationOperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2016-09-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/providers/Microsoft.Authorization/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 AuthorizationOperationsClient) 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 AuthorizationOperationsClient) ListResponder(resp *http.Response) (result OperationListResult, 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 AuthorizationOperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { - req, err := lastResults.operationListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "locks.AuthorizationOperationsClient", "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, "locks.AuthorizationOperationsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.AuthorizationOperationsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client AuthorizationOperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationOperationsClient.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) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/client.go deleted file mode 100644 index fd1b93aad7f6..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/client.go +++ /dev/null @@ -1,43 +0,0 @@ -// Deprecated: Please note, this package has been deprecated. A replacement package is available [github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks). We strongly encourage you to upgrade to continue receiving updates. See [Migration Guide](https://aka.ms/azsdk/golang/t2/migration) for guidance on upgrading. Refer to our [deprecation policy](https://azure.github.io/azure-sdk/policies_support.html) for more details. -// -// Package locks implements the Azure ARM Locks service API version 2016-09-01. -// -// Azure resources can be locked to prevent other users in your organization from deleting or modifying resources. -package locks - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// 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 Locks - DefaultBaseURI = "https://management.azure.com" -) - -// BaseClient is the base client for Locks. -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/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/enums.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/enums.go deleted file mode 100644 index 06a3905244ff..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/enums.go +++ /dev/null @@ -1,24 +0,0 @@ -package locks - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -// LockLevel enumerates the values for lock level. -type LockLevel string - -const ( - // CanNotDelete ... - CanNotDelete LockLevel = "CanNotDelete" - // NotSpecified ... - NotSpecified LockLevel = "NotSpecified" - // ReadOnly ... - ReadOnly LockLevel = "ReadOnly" -) - -// PossibleLockLevelValues returns an array of possible values for the LockLevel const type. -func PossibleLockLevelValues() []LockLevel { - return []LockLevel{CanNotDelete, NotSpecified, ReadOnly} -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/managementlocks.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/managementlocks.go deleted file mode 100644 index 1fe741ce985c..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/managementlocks.go +++ /dev/null @@ -1,1571 +0,0 @@ -package locks - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// 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/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// ManagementLocksClient is the azure resources can be locked to prevent other users in your organization from deleting -// or modifying resources. -type ManagementLocksClient struct { - BaseClient -} - -// NewManagementLocksClient creates an instance of the ManagementLocksClient client. -func NewManagementLocksClient(subscriptionID string) ManagementLocksClient { - return NewManagementLocksClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewManagementLocksClientWithBaseURI creates an instance of the ManagementLocksClient 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 NewManagementLocksClientWithBaseURI(baseURI string, subscriptionID string) ManagementLocksClient { - return ManagementLocksClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdateAtResourceGroupLevel when you apply a lock at a parent scope, all child resources inherit the same -// lock. To create management locks, you must have access to Microsoft.Authorization/* or -// Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted -// those actions. -// Parameters: -// resourceGroupName - the name of the resource group to lock. -// lockName - the lock name. The lock name can be a maximum of 260 characters. It cannot contain <, > %, &, :, -// \, ?, /, or any control characters. -// parameters - the management lock parameters. -func (client ManagementLocksClient) CreateOrUpdateAtResourceGroupLevel(ctx context.Context, resourceGroupName string, lockName string, parameters ManagementLockObject) (result ManagementLockObject, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.CreateOrUpdateAtResourceGroupLevel") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {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: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}, - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.ManagementLockProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewError("locks.ManagementLocksClient", "CreateOrUpdateAtResourceGroupLevel", err.Error()) - } - - req, err := client.CreateOrUpdateAtResourceGroupLevelPreparer(ctx, resourceGroupName, lockName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateAtResourceGroupLevel", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateAtResourceGroupLevelSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateAtResourceGroupLevel", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateAtResourceGroupLevelResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateAtResourceGroupLevel", resp, "Failure responding to request") - return - } - - return -} - -// CreateOrUpdateAtResourceGroupLevelPreparer prepares the CreateOrUpdateAtResourceGroupLevel request. -func (client ManagementLocksClient) CreateOrUpdateAtResourceGroupLevelPreparer(ctx context.Context, resourceGroupName string, lockName string, parameters ManagementLockObject) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "lockName": autorest.Encode("path", lockName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-09-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - parameters.ID = nil - parameters.Type = nil - parameters.Name = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateAtResourceGroupLevelSender sends the CreateOrUpdateAtResourceGroupLevel request. The method will close the -// http.Response Body if it receives an error. -func (client ManagementLocksClient) CreateOrUpdateAtResourceGroupLevelSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateAtResourceGroupLevelResponder handles the response to the CreateOrUpdateAtResourceGroupLevel request. The method always -// closes the http.Response Body. -func (client ManagementLocksClient) CreateOrUpdateAtResourceGroupLevelResponder(resp *http.Response) (result ManagementLockObject, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateOrUpdateAtResourceLevel when you apply a lock at a parent scope, all child resources inherit the same lock. To -// create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* -// actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. -// Parameters: -// resourceGroupName - the name of the resource group containing the resource to lock. -// resourceProviderNamespace - the resource provider namespace of the resource to lock. -// parentResourcePath - the parent resource identity. -// resourceType - the resource type of the resource to lock. -// resourceName - the name of the resource to lock. -// lockName - the name of lock. The lock name can be a maximum of 260 characters. It cannot contain <, > %, &, -// :, \, ?, /, or any control characters. -// parameters - parameters for creating or updating a management lock. -func (client ManagementLocksClient) CreateOrUpdateAtResourceLevel(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string, parameters ManagementLockObject) (result ManagementLockObject, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.CreateOrUpdateAtResourceLevel") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {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: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}, - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.ManagementLockProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewError("locks.ManagementLocksClient", "CreateOrUpdateAtResourceLevel", err.Error()) - } - - req, err := client.CreateOrUpdateAtResourceLevelPreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, lockName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateAtResourceLevel", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateAtResourceLevelSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateAtResourceLevel", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateAtResourceLevelResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateAtResourceLevel", resp, "Failure responding to request") - return - } - - return -} - -// CreateOrUpdateAtResourceLevelPreparer prepares the CreateOrUpdateAtResourceLevel request. -func (client ManagementLocksClient) CreateOrUpdateAtResourceLevelPreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string, parameters ManagementLockObject) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "lockName": autorest.Encode("path", lockName), - "parentResourcePath": parentResourcePath, - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), - "resourceType": resourceType, - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-09-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - parameters.ID = nil - parameters.Type = nil - parameters.Name = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateAtResourceLevelSender sends the CreateOrUpdateAtResourceLevel request. The method will close the -// http.Response Body if it receives an error. -func (client ManagementLocksClient) CreateOrUpdateAtResourceLevelSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateAtResourceLevelResponder handles the response to the CreateOrUpdateAtResourceLevel request. The method always -// closes the http.Response Body. -func (client ManagementLocksClient) CreateOrUpdateAtResourceLevelResponder(resp *http.Response) (result ManagementLockObject, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateOrUpdateAtSubscriptionLevel when you apply a lock at a parent scope, all child resources inherit the same -// lock. To create management locks, you must have access to Microsoft.Authorization/* or -// Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted -// those actions. -// Parameters: -// lockName - the name of lock. The lock name can be a maximum of 260 characters. It cannot contain <, > %, &, -// :, \, ?, /, or any control characters. -// parameters - the management lock parameters. -func (client ManagementLocksClient) CreateOrUpdateAtSubscriptionLevel(ctx context.Context, lockName string, parameters ManagementLockObject) (result ManagementLockObject, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.CreateOrUpdateAtSubscriptionLevel") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.ManagementLockProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewError("locks.ManagementLocksClient", "CreateOrUpdateAtSubscriptionLevel", err.Error()) - } - - req, err := client.CreateOrUpdateAtSubscriptionLevelPreparer(ctx, lockName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateAtSubscriptionLevel", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateAtSubscriptionLevelSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateAtSubscriptionLevel", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateAtSubscriptionLevelResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateAtSubscriptionLevel", resp, "Failure responding to request") - return - } - - return -} - -// CreateOrUpdateAtSubscriptionLevelPreparer prepares the CreateOrUpdateAtSubscriptionLevel request. -func (client ManagementLocksClient) CreateOrUpdateAtSubscriptionLevelPreparer(ctx context.Context, lockName string, parameters ManagementLockObject) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "lockName": autorest.Encode("path", lockName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-09-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - parameters.ID = nil - parameters.Type = nil - parameters.Name = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateAtSubscriptionLevelSender sends the CreateOrUpdateAtSubscriptionLevel request. The method will close the -// http.Response Body if it receives an error. -func (client ManagementLocksClient) CreateOrUpdateAtSubscriptionLevelSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateAtSubscriptionLevelResponder handles the response to the CreateOrUpdateAtSubscriptionLevel request. The method always -// closes the http.Response Body. -func (client ManagementLocksClient) CreateOrUpdateAtSubscriptionLevelResponder(resp *http.Response) (result ManagementLockObject, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateOrUpdateByScope create or update a management lock by scope. -// Parameters: -// scope - the scope for the lock. When providing a scope for the assignment, use -// '/subscriptions/{subscriptionId}' for subscriptions, -// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for resource groups, and -// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' -// for resources. -// lockName - the name of lock. -// parameters - create or update management lock parameters. -func (client ManagementLocksClient) CreateOrUpdateByScope(ctx context.Context, scope string, lockName string, parameters ManagementLockObject) (result ManagementLockObject, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.CreateOrUpdateByScope") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.ManagementLockProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewError("locks.ManagementLocksClient", "CreateOrUpdateByScope", err.Error()) - } - - req, err := client.CreateOrUpdateByScopePreparer(ctx, scope, lockName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateByScope", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateByScopeSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateByScope", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateByScopeResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateByScope", resp, "Failure responding to request") - return - } - - return -} - -// CreateOrUpdateByScopePreparer prepares the CreateOrUpdateByScope request. -func (client ManagementLocksClient) CreateOrUpdateByScopePreparer(ctx context.Context, scope string, lockName string, parameters ManagementLockObject) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "lockName": autorest.Encode("path", lockName), - "scope": autorest.Encode("path", scope), - } - - const APIVersion = "2016-09-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - parameters.ID = nil - parameters.Type = nil - parameters.Name = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateByScopeSender sends the CreateOrUpdateByScope request. The method will close the -// http.Response Body if it receives an error. -func (client ManagementLocksClient) CreateOrUpdateByScopeSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// CreateOrUpdateByScopeResponder handles the response to the CreateOrUpdateByScope request. The method always -// closes the http.Response Body. -func (client ManagementLocksClient) CreateOrUpdateByScopeResponder(resp *http.Response) (result ManagementLockObject, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// DeleteAtResourceGroupLevel to delete management locks, you must have access to Microsoft.Authorization/* or -// Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted -// those actions. -// Parameters: -// resourceGroupName - the name of the resource group containing the lock. -// lockName - the name of lock to delete. -func (client ManagementLocksClient) DeleteAtResourceGroupLevel(ctx context.Context, resourceGroupName string, lockName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.DeleteAtResourceGroupLevel") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {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: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("locks.ManagementLocksClient", "DeleteAtResourceGroupLevel", err.Error()) - } - - req, err := client.DeleteAtResourceGroupLevelPreparer(ctx, resourceGroupName, lockName) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteAtResourceGroupLevel", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteAtResourceGroupLevelSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteAtResourceGroupLevel", resp, "Failure sending request") - return - } - - result, err = client.DeleteAtResourceGroupLevelResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteAtResourceGroupLevel", resp, "Failure responding to request") - return - } - - return -} - -// DeleteAtResourceGroupLevelPreparer prepares the DeleteAtResourceGroupLevel request. -func (client ManagementLocksClient) DeleteAtResourceGroupLevelPreparer(ctx context.Context, resourceGroupName string, lockName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "lockName": autorest.Encode("path", lockName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-09-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteAtResourceGroupLevelSender sends the DeleteAtResourceGroupLevel request. The method will close the -// http.Response Body if it receives an error. -func (client ManagementLocksClient) DeleteAtResourceGroupLevelSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteAtResourceGroupLevelResponder handles the response to the DeleteAtResourceGroupLevel request. The method always -// closes the http.Response Body. -func (client ManagementLocksClient) DeleteAtResourceGroupLevelResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteAtResourceLevel to delete management locks, you must have access to Microsoft.Authorization/* or -// Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted -// those actions. -// Parameters: -// resourceGroupName - the name of the resource group containing the resource with the lock to delete. -// resourceProviderNamespace - the resource provider namespace of the resource with the lock to delete. -// parentResourcePath - the parent resource identity. -// resourceType - the resource type of the resource with the lock to delete. -// resourceName - the name of the resource with the lock to delete. -// lockName - the name of the lock to delete. -func (client ManagementLocksClient) DeleteAtResourceLevel(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.DeleteAtResourceLevel") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {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: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("locks.ManagementLocksClient", "DeleteAtResourceLevel", err.Error()) - } - - req, err := client.DeleteAtResourceLevelPreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, lockName) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteAtResourceLevel", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteAtResourceLevelSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteAtResourceLevel", resp, "Failure sending request") - return - } - - result, err = client.DeleteAtResourceLevelResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteAtResourceLevel", resp, "Failure responding to request") - return - } - - return -} - -// DeleteAtResourceLevelPreparer prepares the DeleteAtResourceLevel request. -func (client ManagementLocksClient) DeleteAtResourceLevelPreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "lockName": autorest.Encode("path", lockName), - "parentResourcePath": parentResourcePath, - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), - "resourceType": resourceType, - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-09-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteAtResourceLevelSender sends the DeleteAtResourceLevel request. The method will close the -// http.Response Body if it receives an error. -func (client ManagementLocksClient) DeleteAtResourceLevelSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteAtResourceLevelResponder handles the response to the DeleteAtResourceLevel request. The method always -// closes the http.Response Body. -func (client ManagementLocksClient) DeleteAtResourceLevelResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteAtSubscriptionLevel to delete management locks, you must have access to Microsoft.Authorization/* or -// Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted -// those actions. -// Parameters: -// lockName - the name of lock to delete. -func (client ManagementLocksClient) DeleteAtSubscriptionLevel(ctx context.Context, lockName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.DeleteAtSubscriptionLevel") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.DeleteAtSubscriptionLevelPreparer(ctx, lockName) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteAtSubscriptionLevel", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteAtSubscriptionLevelSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteAtSubscriptionLevel", resp, "Failure sending request") - return - } - - result, err = client.DeleteAtSubscriptionLevelResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteAtSubscriptionLevel", resp, "Failure responding to request") - return - } - - return -} - -// DeleteAtSubscriptionLevelPreparer prepares the DeleteAtSubscriptionLevel request. -func (client ManagementLocksClient) DeleteAtSubscriptionLevelPreparer(ctx context.Context, lockName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "lockName": autorest.Encode("path", lockName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-09-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteAtSubscriptionLevelSender sends the DeleteAtSubscriptionLevel request. The method will close the -// http.Response Body if it receives an error. -func (client ManagementLocksClient) DeleteAtSubscriptionLevelSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteAtSubscriptionLevelResponder handles the response to the DeleteAtSubscriptionLevel request. The method always -// closes the http.Response Body. -func (client ManagementLocksClient) DeleteAtSubscriptionLevelResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteByScope delete a management lock by scope. -// Parameters: -// scope - the scope for the lock. -// lockName - the name of lock. -func (client ManagementLocksClient) DeleteByScope(ctx context.Context, scope string, lockName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.DeleteByScope") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.DeleteByScopePreparer(ctx, scope, lockName) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteByScope", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteByScopeSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteByScope", resp, "Failure sending request") - return - } - - result, err = client.DeleteByScopeResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteByScope", resp, "Failure responding to request") - return - } - - return -} - -// DeleteByScopePreparer prepares the DeleteByScope request. -func (client ManagementLocksClient) DeleteByScopePreparer(ctx context.Context, scope string, lockName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "lockName": autorest.Encode("path", lockName), - "scope": autorest.Encode("path", scope), - } - - const APIVersion = "2016-09-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteByScopeSender sends the DeleteByScope request. The method will close the -// http.Response Body if it receives an error. -func (client ManagementLocksClient) DeleteByScopeSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// DeleteByScopeResponder handles the response to the DeleteByScope request. The method always -// closes the http.Response Body. -func (client ManagementLocksClient) DeleteByScopeResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// GetAtResourceGroupLevel gets a management lock at the resource group level. -// Parameters: -// resourceGroupName - the name of the locked resource group. -// lockName - the name of the lock to get. -func (client ManagementLocksClient) GetAtResourceGroupLevel(ctx context.Context, resourceGroupName string, lockName string) (result ManagementLockObject, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.GetAtResourceGroupLevel") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {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: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("locks.ManagementLocksClient", "GetAtResourceGroupLevel", err.Error()) - } - - req, err := client.GetAtResourceGroupLevelPreparer(ctx, resourceGroupName, lockName) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetAtResourceGroupLevel", nil, "Failure preparing request") - return - } - - resp, err := client.GetAtResourceGroupLevelSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetAtResourceGroupLevel", resp, "Failure sending request") - return - } - - result, err = client.GetAtResourceGroupLevelResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetAtResourceGroupLevel", resp, "Failure responding to request") - return - } - - return -} - -// GetAtResourceGroupLevelPreparer prepares the GetAtResourceGroupLevel request. -func (client ManagementLocksClient) GetAtResourceGroupLevelPreparer(ctx context.Context, resourceGroupName string, lockName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "lockName": autorest.Encode("path", lockName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-09-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetAtResourceGroupLevelSender sends the GetAtResourceGroupLevel request. The method will close the -// http.Response Body if it receives an error. -func (client ManagementLocksClient) GetAtResourceGroupLevelSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetAtResourceGroupLevelResponder handles the response to the GetAtResourceGroupLevel request. The method always -// closes the http.Response Body. -func (client ManagementLocksClient) GetAtResourceGroupLevelResponder(resp *http.Response) (result ManagementLockObject, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetAtResourceLevel get the management lock of a resource or any level below resource. -// Parameters: -// resourceGroupName - the name of the resource group. -// resourceProviderNamespace - the namespace of the resource provider. -// parentResourcePath - an extra path parameter needed in some services, like SQL Databases. -// resourceType - the type of the resource. -// resourceName - the name of the resource. -// lockName - the name of lock. -func (client ManagementLocksClient) GetAtResourceLevel(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string) (result ManagementLockObject, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.GetAtResourceLevel") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {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: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("locks.ManagementLocksClient", "GetAtResourceLevel", err.Error()) - } - - req, err := client.GetAtResourceLevelPreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, lockName) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetAtResourceLevel", nil, "Failure preparing request") - return - } - - resp, err := client.GetAtResourceLevelSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetAtResourceLevel", resp, "Failure sending request") - return - } - - result, err = client.GetAtResourceLevelResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetAtResourceLevel", resp, "Failure responding to request") - return - } - - return -} - -// GetAtResourceLevelPreparer prepares the GetAtResourceLevel request. -func (client ManagementLocksClient) GetAtResourceLevelPreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "lockName": autorest.Encode("path", lockName), - "parentResourcePath": parentResourcePath, - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), - "resourceType": resourceType, - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-09-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetAtResourceLevelSender sends the GetAtResourceLevel request. The method will close the -// http.Response Body if it receives an error. -func (client ManagementLocksClient) GetAtResourceLevelSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetAtResourceLevelResponder handles the response to the GetAtResourceLevel request. The method always -// closes the http.Response Body. -func (client ManagementLocksClient) GetAtResourceLevelResponder(resp *http.Response) (result ManagementLockObject, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetAtSubscriptionLevel gets a management lock at the subscription level. -// Parameters: -// lockName - the name of the lock to get. -func (client ManagementLocksClient) GetAtSubscriptionLevel(ctx context.Context, lockName string) (result ManagementLockObject, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.GetAtSubscriptionLevel") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetAtSubscriptionLevelPreparer(ctx, lockName) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetAtSubscriptionLevel", nil, "Failure preparing request") - return - } - - resp, err := client.GetAtSubscriptionLevelSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetAtSubscriptionLevel", resp, "Failure sending request") - return - } - - result, err = client.GetAtSubscriptionLevelResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetAtSubscriptionLevel", resp, "Failure responding to request") - return - } - - return -} - -// GetAtSubscriptionLevelPreparer prepares the GetAtSubscriptionLevel request. -func (client ManagementLocksClient) GetAtSubscriptionLevelPreparer(ctx context.Context, lockName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "lockName": autorest.Encode("path", lockName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-09-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetAtSubscriptionLevelSender sends the GetAtSubscriptionLevel request. The method will close the -// http.Response Body if it receives an error. -func (client ManagementLocksClient) GetAtSubscriptionLevelSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetAtSubscriptionLevelResponder handles the response to the GetAtSubscriptionLevel request. The method always -// closes the http.Response Body. -func (client ManagementLocksClient) GetAtSubscriptionLevelResponder(resp *http.Response) (result ManagementLockObject, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetByScope get a management lock by scope. -// Parameters: -// scope - the scope for the lock. -// lockName - the name of lock. -func (client ManagementLocksClient) GetByScope(ctx context.Context, scope string, lockName string) (result ManagementLockObject, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.GetByScope") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetByScopePreparer(ctx, scope, lockName) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetByScope", nil, "Failure preparing request") - return - } - - resp, err := client.GetByScopeSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetByScope", resp, "Failure sending request") - return - } - - result, err = client.GetByScopeResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetByScope", resp, "Failure responding to request") - return - } - - return -} - -// GetByScopePreparer prepares the GetByScope request. -func (client ManagementLocksClient) GetByScopePreparer(ctx context.Context, scope string, lockName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "lockName": autorest.Encode("path", lockName), - "scope": autorest.Encode("path", scope), - } - - const APIVersion = "2016-09-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetByScopeSender sends the GetByScope request. The method will close the -// http.Response Body if it receives an error. -func (client ManagementLocksClient) GetByScopeSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// GetByScopeResponder handles the response to the GetByScope request. The method always -// closes the http.Response Body. -func (client ManagementLocksClient) GetByScopeResponder(resp *http.Response) (result ManagementLockObject, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListAtResourceGroupLevel gets all the management locks for a resource group. -// Parameters: -// resourceGroupName - the name of the resource group containing the locks to get. -// filter - the filter to apply on the operation. -func (client ManagementLocksClient) ListAtResourceGroupLevel(ctx context.Context, resourceGroupName string, filter string) (result ManagementLockListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.ListAtResourceGroupLevel") - defer func() { - sc := -1 - if result.mllr.Response.Response != nil { - sc = result.mllr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {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: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("locks.ManagementLocksClient", "ListAtResourceGroupLevel", err.Error()) - } - - result.fn = client.listAtResourceGroupLevelNextResults - req, err := client.ListAtResourceGroupLevelPreparer(ctx, resourceGroupName, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListAtResourceGroupLevel", nil, "Failure preparing request") - return - } - - resp, err := client.ListAtResourceGroupLevelSender(req) - if err != nil { - result.mllr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListAtResourceGroupLevel", resp, "Failure sending request") - return - } - - result.mllr, err = client.ListAtResourceGroupLevelResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListAtResourceGroupLevel", resp, "Failure responding to request") - return - } - if result.mllr.hasNextLink() && result.mllr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListAtResourceGroupLevelPreparer prepares the ListAtResourceGroupLevel request. -func (client ManagementLocksClient) ListAtResourceGroupLevelPreparer(ctx context.Context, resourceGroupName string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-09-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListAtResourceGroupLevelSender sends the ListAtResourceGroupLevel request. The method will close the -// http.Response Body if it receives an error. -func (client ManagementLocksClient) ListAtResourceGroupLevelSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListAtResourceGroupLevelResponder handles the response to the ListAtResourceGroupLevel request. The method always -// closes the http.Response Body. -func (client ManagementLocksClient) ListAtResourceGroupLevelResponder(resp *http.Response) (result ManagementLockListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listAtResourceGroupLevelNextResults retrieves the next set of results, if any. -func (client ManagementLocksClient) listAtResourceGroupLevelNextResults(ctx context.Context, lastResults ManagementLockListResult) (result ManagementLockListResult, err error) { - req, err := lastResults.managementLockListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listAtResourceGroupLevelNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListAtResourceGroupLevelSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listAtResourceGroupLevelNextResults", resp, "Failure sending next results request") - } - result, err = client.ListAtResourceGroupLevelResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listAtResourceGroupLevelNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListAtResourceGroupLevelComplete enumerates all values, automatically crossing page boundaries as required. -func (client ManagementLocksClient) ListAtResourceGroupLevelComplete(ctx context.Context, resourceGroupName string, filter string) (result ManagementLockListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.ListAtResourceGroupLevel") - 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.ListAtResourceGroupLevel(ctx, resourceGroupName, filter) - return -} - -// ListAtResourceLevel gets all the management locks for a resource or any level below resource. -// Parameters: -// resourceGroupName - the name of the resource group containing the locked resource. The name is case -// insensitive. -// resourceProviderNamespace - the namespace of the resource provider. -// parentResourcePath - the parent resource identity. -// resourceType - the resource type of the locked resource. -// resourceName - the name of the locked resource. -// filter - the filter to apply on the operation. -func (client ManagementLocksClient) ListAtResourceLevel(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (result ManagementLockListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.ListAtResourceLevel") - defer func() { - sc := -1 - if result.mllr.Response.Response != nil { - sc = result.mllr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {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: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("locks.ManagementLocksClient", "ListAtResourceLevel", err.Error()) - } - - result.fn = client.listAtResourceLevelNextResults - req, err := client.ListAtResourceLevelPreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListAtResourceLevel", nil, "Failure preparing request") - return - } - - resp, err := client.ListAtResourceLevelSender(req) - if err != nil { - result.mllr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListAtResourceLevel", resp, "Failure sending request") - return - } - - result.mllr, err = client.ListAtResourceLevelResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListAtResourceLevel", resp, "Failure responding to request") - return - } - if result.mllr.hasNextLink() && result.mllr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListAtResourceLevelPreparer prepares the ListAtResourceLevel request. -func (client ManagementLocksClient) ListAtResourceLevelPreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "parentResourcePath": parentResourcePath, - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), - "resourceType": resourceType, - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-09-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListAtResourceLevelSender sends the ListAtResourceLevel request. The method will close the -// http.Response Body if it receives an error. -func (client ManagementLocksClient) ListAtResourceLevelSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListAtResourceLevelResponder handles the response to the ListAtResourceLevel request. The method always -// closes the http.Response Body. -func (client ManagementLocksClient) ListAtResourceLevelResponder(resp *http.Response) (result ManagementLockListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listAtResourceLevelNextResults retrieves the next set of results, if any. -func (client ManagementLocksClient) listAtResourceLevelNextResults(ctx context.Context, lastResults ManagementLockListResult) (result ManagementLockListResult, err error) { - req, err := lastResults.managementLockListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listAtResourceLevelNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListAtResourceLevelSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listAtResourceLevelNextResults", resp, "Failure sending next results request") - } - result, err = client.ListAtResourceLevelResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listAtResourceLevelNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListAtResourceLevelComplete enumerates all values, automatically crossing page boundaries as required. -func (client ManagementLocksClient) ListAtResourceLevelComplete(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (result ManagementLockListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.ListAtResourceLevel") - 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.ListAtResourceLevel(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter) - return -} - -// ListAtSubscriptionLevel gets all the management locks for a subscription. -// Parameters: -// filter - the filter to apply on the operation. -func (client ManagementLocksClient) ListAtSubscriptionLevel(ctx context.Context, filter string) (result ManagementLockListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.ListAtSubscriptionLevel") - defer func() { - sc := -1 - if result.mllr.Response.Response != nil { - sc = result.mllr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listAtSubscriptionLevelNextResults - req, err := client.ListAtSubscriptionLevelPreparer(ctx, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListAtSubscriptionLevel", nil, "Failure preparing request") - return - } - - resp, err := client.ListAtSubscriptionLevelSender(req) - if err != nil { - result.mllr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListAtSubscriptionLevel", resp, "Failure sending request") - return - } - - result.mllr, err = client.ListAtSubscriptionLevelResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListAtSubscriptionLevel", resp, "Failure responding to request") - return - } - if result.mllr.hasNextLink() && result.mllr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListAtSubscriptionLevelPreparer prepares the ListAtSubscriptionLevel request. -func (client ManagementLocksClient) ListAtSubscriptionLevelPreparer(ctx context.Context, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-09-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListAtSubscriptionLevelSender sends the ListAtSubscriptionLevel request. The method will close the -// http.Response Body if it receives an error. -func (client ManagementLocksClient) ListAtSubscriptionLevelSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListAtSubscriptionLevelResponder handles the response to the ListAtSubscriptionLevel request. The method always -// closes the http.Response Body. -func (client ManagementLocksClient) ListAtSubscriptionLevelResponder(resp *http.Response) (result ManagementLockListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listAtSubscriptionLevelNextResults retrieves the next set of results, if any. -func (client ManagementLocksClient) listAtSubscriptionLevelNextResults(ctx context.Context, lastResults ManagementLockListResult) (result ManagementLockListResult, err error) { - req, err := lastResults.managementLockListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listAtSubscriptionLevelNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListAtSubscriptionLevelSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listAtSubscriptionLevelNextResults", resp, "Failure sending next results request") - } - result, err = client.ListAtSubscriptionLevelResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listAtSubscriptionLevelNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListAtSubscriptionLevelComplete enumerates all values, automatically crossing page boundaries as required. -func (client ManagementLocksClient) ListAtSubscriptionLevelComplete(ctx context.Context, filter string) (result ManagementLockListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.ListAtSubscriptionLevel") - 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.ListAtSubscriptionLevel(ctx, filter) - return -} - -// ListByScope gets all the management locks for a scope. -// Parameters: -// scope - the scope for the lock. When providing a scope for the assignment, use -// '/subscriptions/{subscriptionId}' for subscriptions, -// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for resource groups, and -// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' -// for resources. -// filter - the filter to apply on the operation. -func (client ManagementLocksClient) ListByScope(ctx context.Context, scope string, filter string) (result ManagementLockListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.ListByScope") - defer func() { - sc := -1 - if result.mllr.Response.Response != nil { - sc = result.mllr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listByScopeNextResults - req, err := client.ListByScopePreparer(ctx, scope, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListByScope", nil, "Failure preparing request") - return - } - - resp, err := client.ListByScopeSender(req) - if err != nil { - result.mllr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListByScope", resp, "Failure sending request") - return - } - - result.mllr, err = client.ListByScopeResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListByScope", resp, "Failure responding to request") - return - } - if result.mllr.hasNextLink() && result.mllr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListByScopePreparer prepares the ListByScope request. -func (client ManagementLocksClient) ListByScopePreparer(ctx context.Context, scope string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "scope": autorest.Encode("path", scope), - } - - const APIVersion = "2016-09-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/locks", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListByScopeSender sends the ListByScope request. The method will close the -// http.Response Body if it receives an error. -func (client ManagementLocksClient) ListByScopeSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// ListByScopeResponder handles the response to the ListByScope request. The method always -// closes the http.Response Body. -func (client ManagementLocksClient) ListByScopeResponder(resp *http.Response) (result ManagementLockListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listByScopeNextResults retrieves the next set of results, if any. -func (client ManagementLocksClient) listByScopeNextResults(ctx context.Context, lastResults ManagementLockListResult) (result ManagementLockListResult, err error) { - req, err := lastResults.managementLockListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listByScopeNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListByScopeSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listByScopeNextResults", resp, "Failure sending next results request") - } - result, err = client.ListByScopeResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listByScopeNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListByScopeComplete enumerates all values, automatically crossing page boundaries as required. -func (client ManagementLocksClient) ListByScopeComplete(ctx context.Context, scope string, filter string) (result ManagementLockListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.ListByScope") - 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.ListByScope(ctx, scope, filter) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/models.go deleted file mode 100644 index 5e44750dbfc6..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/models.go +++ /dev/null @@ -1,445 +0,0 @@ -package locks - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// 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/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/resources/mgmt/2016-09-01/locks" - -// ManagementLockListResult the list of locks. -type ManagementLockListResult struct { - autorest.Response `json:"-"` - // Value - The list of locks. - Value *[]ManagementLockObject `json:"value,omitempty"` - // NextLink - The URL to use for getting the next set of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// ManagementLockListResultIterator provides access to a complete listing of ManagementLockObject values. -type ManagementLockListResultIterator struct { - i int - page ManagementLockListResultPage -} - -// 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 *ManagementLockListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLockListResultIterator.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 *ManagementLockListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ManagementLockListResultIterator) 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 ManagementLockListResultIterator) Response() ManagementLockListResult { - 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 ManagementLockListResultIterator) Value() ManagementLockObject { - if !iter.page.NotDone() { - return ManagementLockObject{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the ManagementLockListResultIterator type. -func NewManagementLockListResultIterator(page ManagementLockListResultPage) ManagementLockListResultIterator { - return ManagementLockListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (mllr ManagementLockListResult) IsEmpty() bool { - return mllr.Value == nil || len(*mllr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (mllr ManagementLockListResult) hasNextLink() bool { - return mllr.NextLink != nil && len(*mllr.NextLink) != 0 -} - -// managementLockListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (mllr ManagementLockListResult) managementLockListResultPreparer(ctx context.Context) (*http.Request, error) { - if !mllr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(mllr.NextLink))) -} - -// ManagementLockListResultPage contains a page of ManagementLockObject values. -type ManagementLockListResultPage struct { - fn func(context.Context, ManagementLockListResult) (ManagementLockListResult, error) - mllr ManagementLockListResult -} - -// 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 *ManagementLockListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLockListResultPage.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.mllr) - if err != nil { - return err - } - page.mllr = 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 *ManagementLockListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ManagementLockListResultPage) NotDone() bool { - return !page.mllr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page ManagementLockListResultPage) Response() ManagementLockListResult { - return page.mllr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page ManagementLockListResultPage) Values() []ManagementLockObject { - if page.mllr.IsEmpty() { - return nil - } - return *page.mllr.Value -} - -// Creates a new instance of the ManagementLockListResultPage type. -func NewManagementLockListResultPage(cur ManagementLockListResult, getNextPage func(context.Context, ManagementLockListResult) (ManagementLockListResult, error)) ManagementLockListResultPage { - return ManagementLockListResultPage{ - fn: getNextPage, - mllr: cur, - } -} - -// ManagementLockObject the lock information. -type ManagementLockObject struct { - autorest.Response `json:"-"` - // ManagementLockProperties - The properties of the lock. - *ManagementLockProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The resource ID of the lock. - ID *string `json:"id,omitempty"` - // Type - READ-ONLY; The resource type of the lock - Microsoft.Authorization/locks. - Type *string `json:"type,omitempty"` - // Name - READ-ONLY; The name of the lock. - Name *string `json:"name,omitempty"` -} - -// MarshalJSON is the custom marshaler for ManagementLockObject. -func (mlo ManagementLockObject) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mlo.ManagementLockProperties != nil { - objectMap["properties"] = mlo.ManagementLockProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for ManagementLockObject struct. -func (mlo *ManagementLockObject) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var managementLockProperties ManagementLockProperties - err = json.Unmarshal(*v, &managementLockProperties) - if err != nil { - return err - } - mlo.ManagementLockProperties = &managementLockProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - mlo.ID = &ID - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - mlo.Type = &typeVar - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - mlo.Name = &name - } - } - } - - return nil -} - -// ManagementLockOwner lock owner properties. -type ManagementLockOwner struct { - // ApplicationID - The application ID of the lock owner. - ApplicationID *string `json:"applicationId,omitempty"` -} - -// ManagementLockProperties the lock properties. -type ManagementLockProperties struct { - // Level - The level of the lock. Possible values are: NotSpecified, CanNotDelete, ReadOnly. CanNotDelete means authorized users are able to read and modify the resources, but not delete. ReadOnly means authorized users can only read from a resource, but they can't modify or delete it. Possible values include: 'NotSpecified', 'CanNotDelete', 'ReadOnly' - Level LockLevel `json:"level,omitempty"` - // Notes - Notes about the lock. Maximum of 512 characters. - Notes *string `json:"notes,omitempty"` - // Owners - The owners of the lock. - Owners *[]ManagementLockOwner `json:"owners,omitempty"` -} - -// Operation microsoft.Authorization operation -type Operation struct { - // Name - Operation name: {provider}/{resource}/{operation} - Name *string `json:"name,omitempty"` - // Display - The object that represents the operation. - Display *OperationDisplay `json:"display,omitempty"` -} - -// OperationDisplay the object that represents the operation. -type OperationDisplay struct { - // Provider - Service provider: Microsoft.Authorization - Provider *string `json:"provider,omitempty"` - // Resource - Resource on which the operation is performed: Profile, endpoint, etc. - Resource *string `json:"resource,omitempty"` - // Operation - Operation type: Read, write, delete, etc. - Operation *string `json:"operation,omitempty"` -} - -// OperationListResult result of the request to list Microsoft.Authorization operations. It contains a list -// of operations and a URL link to get the next set of results. -type OperationListResult struct { - autorest.Response `json:"-"` - // Value - List of Microsoft.Authorization operations. - Value *[]Operation `json:"value,omitempty"` - // NextLink - URL to get the next set of operation list results if there are any. - NextLink *string `json:"nextLink,omitempty"` -} - -// OperationListResultIterator provides access to a complete listing of Operation values. -type OperationListResultIterator struct { - i int - page OperationListResultPage -} - -// 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 *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.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 *OperationListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter OperationListResultIterator) 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 OperationListResultIterator) Response() OperationListResult { - 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 OperationListResultIterator) Value() Operation { - if !iter.page.NotDone() { - return Operation{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the OperationListResultIterator type. -func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { - return OperationListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (olr OperationListResult) IsEmpty() bool { - return olr.Value == nil || len(*olr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (olr OperationListResult) hasNextLink() bool { - return olr.NextLink != nil && len(*olr.NextLink) != 0 -} - -// operationListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { - if !olr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(olr.NextLink))) -} - -// OperationListResultPage contains a page of Operation values. -type OperationListResultPage struct { - fn func(context.Context, OperationListResult) (OperationListResult, error) - olr OperationListResult -} - -// 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 *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.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.olr) - if err != nil { - return err - } - page.olr = 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 *OperationListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page OperationListResultPage) NotDone() bool { - return !page.olr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page OperationListResultPage) Response() OperationListResult { - return page.olr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page OperationListResultPage) Values() []Operation { - if page.olr.IsEmpty() { - return nil - } - return *page.olr.Value -} - -// Creates a new instance of the OperationListResultPage type. -func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { - return OperationListResultPage{ - fn: getNextPage, - olr: cur, - } -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/version.go deleted file mode 100644 index 22dc8ee7dac8..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks/version.go +++ /dev/null @@ -1,19 +0,0 @@ -package locks - -import "github.com/Azure/azure-sdk-for-go/version" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// 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() + " locks/2016-09-01" -} - -// Version returns the semantic version (see http://semver.org) of the client. -func Version() string { - return version.Number -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/README.md new file mode 100644 index 000000000000..718d58ae1875 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/README.md @@ -0,0 +1,300 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks` Documentation + +The `managementlocks` SDK allows for interaction with the Azure Resource Manager Service `resources` (API Version `2020-05-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks" +``` + + +### Client Initialization + +```go +client := managementlocks.NewManagementLocksClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagementLocksClient.CreateOrUpdateAtResourceGroupLevel` + +```go +ctx := context.TODO() +id := managementlocks.NewProviderLockID("12345678-1234-9876-4563-123456789012", "example-resource-group", "lockValue") + +payload := managementlocks.ManagementLockObject{ + // ... +} + + +read, err := client.CreateOrUpdateAtResourceGroupLevel(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementLocksClient.CreateOrUpdateAtResourceLevel` + +```go +ctx := context.TODO() +id := managementlocks.NewResourceLockID("12345678-1234-9876-4563-123456789012", "example-resource-group", "providerValue", "parentResourcePathValue", "resourceTypeValue", "resourceValue", "lockValue") + +payload := managementlocks.ManagementLockObject{ + // ... +} + + +read, err := client.CreateOrUpdateAtResourceLevel(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementLocksClient.CreateOrUpdateAtSubscriptionLevel` + +```go +ctx := context.TODO() +id := managementlocks.NewLockID("12345678-1234-9876-4563-123456789012", "lockValue") + +payload := managementlocks.ManagementLockObject{ + // ... +} + + +read, err := client.CreateOrUpdateAtSubscriptionLevel(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementLocksClient.CreateOrUpdateByScope` + +```go +ctx := context.TODO() +id := managementlocks.NewScopedLockID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "lockValue") + +payload := managementlocks.ManagementLockObject{ + // ... +} + + +read, err := client.CreateOrUpdateByScope(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementLocksClient.DeleteAtResourceGroupLevel` + +```go +ctx := context.TODO() +id := managementlocks.NewProviderLockID("12345678-1234-9876-4563-123456789012", "example-resource-group", "lockValue") + +read, err := client.DeleteAtResourceGroupLevel(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementLocksClient.DeleteAtResourceLevel` + +```go +ctx := context.TODO() +id := managementlocks.NewResourceLockID("12345678-1234-9876-4563-123456789012", "example-resource-group", "providerValue", "parentResourcePathValue", "resourceTypeValue", "resourceValue", "lockValue") + +read, err := client.DeleteAtResourceLevel(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementLocksClient.DeleteAtSubscriptionLevel` + +```go +ctx := context.TODO() +id := managementlocks.NewLockID("12345678-1234-9876-4563-123456789012", "lockValue") + +read, err := client.DeleteAtSubscriptionLevel(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementLocksClient.DeleteByScope` + +```go +ctx := context.TODO() +id := managementlocks.NewScopedLockID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "lockValue") + +read, err := client.DeleteByScope(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementLocksClient.GetAtResourceGroupLevel` + +```go +ctx := context.TODO() +id := managementlocks.NewProviderLockID("12345678-1234-9876-4563-123456789012", "example-resource-group", "lockValue") + +read, err := client.GetAtResourceGroupLevel(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementLocksClient.GetAtResourceLevel` + +```go +ctx := context.TODO() +id := managementlocks.NewResourceLockID("12345678-1234-9876-4563-123456789012", "example-resource-group", "providerValue", "parentResourcePathValue", "resourceTypeValue", "resourceValue", "lockValue") + +read, err := client.GetAtResourceLevel(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementLocksClient.GetAtSubscriptionLevel` + +```go +ctx := context.TODO() +id := managementlocks.NewLockID("12345678-1234-9876-4563-123456789012", "lockValue") + +read, err := client.GetAtSubscriptionLevel(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementLocksClient.GetByScope` + +```go +ctx := context.TODO() +id := managementlocks.NewScopedLockID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "lockValue") + +read, err := client.GetByScope(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementLocksClient.ListAtResourceGroupLevel` + +```go +ctx := context.TODO() +id := managementlocks.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListAtResourceGroupLevel(ctx, id, managementlocks.DefaultListAtResourceGroupLevelOperationOptions())` can be used to do batched pagination +items, err := client.ListAtResourceGroupLevelComplete(ctx, id, managementlocks.DefaultListAtResourceGroupLevelOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagementLocksClient.ListAtResourceLevel` + +```go +ctx := context.TODO() +id := managementlocks.NewResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "providerValue", "parentResourcePathValue", "resourceTypeValue", "resourceValue") + +// alternatively `client.ListAtResourceLevel(ctx, id, managementlocks.DefaultListAtResourceLevelOperationOptions())` can be used to do batched pagination +items, err := client.ListAtResourceLevelComplete(ctx, id, managementlocks.DefaultListAtResourceLevelOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagementLocksClient.ListAtSubscriptionLevel` + +```go +ctx := context.TODO() +id := managementlocks.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAtSubscriptionLevel(ctx, id, managementlocks.DefaultListAtSubscriptionLevelOperationOptions())` can be used to do batched pagination +items, err := client.ListAtSubscriptionLevelComplete(ctx, id, managementlocks.DefaultListAtSubscriptionLevelOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagementLocksClient.ListByScope` + +```go +ctx := context.TODO() +id := managementlocks.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +// alternatively `client.ListByScope(ctx, id, managementlocks.DefaultListByScopeOperationOptions())` can be used to do batched pagination +items, err := client.ListByScopeComplete(ctx, id, managementlocks.DefaultListByScopeOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/client.go new file mode 100644 index 000000000000..c1a4a1eeb007 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/client.go @@ -0,0 +1,18 @@ +package managementlocks + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagementLocksClient struct { + Client autorest.Client + baseUri string +} + +func NewManagementLocksClientWithBaseURI(endpoint string) ManagementLocksClient { + return ManagementLocksClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/constants.go new file mode 100644 index 000000000000..b50125fc5756 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/constants.go @@ -0,0 +1,37 @@ +package managementlocks + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LockLevel string + +const ( + LockLevelCanNotDelete LockLevel = "CanNotDelete" + LockLevelNotSpecified LockLevel = "NotSpecified" + LockLevelReadOnly LockLevel = "ReadOnly" +) + +func PossibleValuesForLockLevel() []string { + return []string{ + string(LockLevelCanNotDelete), + string(LockLevelNotSpecified), + string(LockLevelReadOnly), + } +} + +func parseLockLevel(input string) (*LockLevel, error) { + vals := map[string]LockLevel{ + "cannotdelete": LockLevelCanNotDelete, + "notspecified": LockLevelNotSpecified, + "readonly": LockLevelReadOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LockLevel(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/id_lock.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/id_lock.go new file mode 100644 index 000000000000..22df14683f5a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/id_lock.go @@ -0,0 +1,111 @@ +package managementlocks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = LockId{} + +// LockId is a struct representing the Resource ID for a Lock +type LockId struct { + SubscriptionId string + LockName string +} + +// NewLockID returns a new LockId struct +func NewLockID(subscriptionId string, lockName string) LockId { + return LockId{ + SubscriptionId: subscriptionId, + LockName: lockName, + } +} + +// ParseLockID parses 'input' into a LockId +func ParseLockID(input string) (*LockId, error) { + parser := resourceids.NewParserFromResourceIdType(LockId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := LockId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.LockName, ok = parsed.Parsed["lockName"]; !ok { + return nil, fmt.Errorf("the segment 'lockName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseLockIDInsensitively parses 'input' case-insensitively into a LockId +// note: this method should only be used for API response data and not user input +func ParseLockIDInsensitively(input string) (*LockId, error) { + parser := resourceids.NewParserFromResourceIdType(LockId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := LockId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.LockName, ok = parsed.Parsed["lockName"]; !ok { + return nil, fmt.Errorf("the segment 'lockName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateLockID checks that 'input' can be parsed as a Lock ID +func ValidateLockID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLockID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Lock ID +func (id LockId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Authorization/locks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LockName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Lock ID +func (id LockId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticLocks", "locks", "locks"), + resourceids.UserSpecifiedSegment("lockName", "lockValue"), + } +} + +// String returns a human-readable description of this Lock ID +func (id LockId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Lock Name: %q", id.LockName), + } + return fmt.Sprintf("Lock (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/id_providerlock.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/id_providerlock.go new file mode 100644 index 000000000000..1a5a282f4f04 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/id_providerlock.go @@ -0,0 +1,124 @@ +package managementlocks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = ProviderLockId{} + +// ProviderLockId is a struct representing the Resource ID for a Provider Lock +type ProviderLockId struct { + SubscriptionId string + ResourceGroupName string + LockName string +} + +// NewProviderLockID returns a new ProviderLockId struct +func NewProviderLockID(subscriptionId string, resourceGroupName string, lockName string) ProviderLockId { + return ProviderLockId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LockName: lockName, + } +} + +// ParseProviderLockID parses 'input' into a ProviderLockId +func ParseProviderLockID(input string) (*ProviderLockId, error) { + parser := resourceids.NewParserFromResourceIdType(ProviderLockId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ProviderLockId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.LockName, ok = parsed.Parsed["lockName"]; !ok { + return nil, fmt.Errorf("the segment 'lockName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseProviderLockIDInsensitively parses 'input' case-insensitively into a ProviderLockId +// note: this method should only be used for API response data and not user input +func ParseProviderLockIDInsensitively(input string) (*ProviderLockId, error) { + parser := resourceids.NewParserFromResourceIdType(ProviderLockId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ProviderLockId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.LockName, ok = parsed.Parsed["lockName"]; !ok { + return nil, fmt.Errorf("the segment 'lockName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateProviderLockID checks that 'input' can be parsed as a Provider Lock ID +func ValidateProviderLockID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderLockID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Lock ID +func (id ProviderLockId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Authorization/locks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LockName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Lock ID +func (id ProviderLockId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticLocks", "locks", "locks"), + resourceids.UserSpecifiedSegment("lockName", "lockValue"), + } +} + +// String returns a human-readable description of this Provider Lock ID +func (id ProviderLockId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Lock Name: %q", id.LockName), + } + return fmt.Sprintf("Provider Lock (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/id_resource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/id_resource.go new file mode 100644 index 000000000000..15cc88c74424 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/id_resource.go @@ -0,0 +1,158 @@ +package managementlocks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = ResourceId{} + +// ResourceId is a struct representing the Resource ID for a Resource +type ResourceId struct { + SubscriptionId string + ResourceGroupName string + ProviderName string + ParentResourcePath string + ResourceType string + ResourceName string +} + +// NewResourceID returns a new ResourceId struct +func NewResourceID(subscriptionId string, resourceGroupName string, providerName string, parentResourcePath string, resourceType string, resourceName string) ResourceId { + return ResourceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProviderName: providerName, + ParentResourcePath: parentResourcePath, + ResourceType: resourceType, + ResourceName: resourceName, + } +} + +// ParseResourceID parses 'input' into a ResourceId +func ParseResourceID(input string) (*ResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(ResourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ResourceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ProviderName, ok = parsed.Parsed["providerName"]; !ok { + return nil, fmt.Errorf("the segment 'providerName' was not found in the resource id %q", input) + } + + if id.ParentResourcePath, ok = parsed.Parsed["parentResourcePath"]; !ok { + return nil, fmt.Errorf("the segment 'parentResourcePath' was not found in the resource id %q", input) + } + + if id.ResourceType, ok = parsed.Parsed["resourceType"]; !ok { + return nil, fmt.Errorf("the segment 'resourceType' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseResourceIDInsensitively parses 'input' case-insensitively into a ResourceId +// note: this method should only be used for API response data and not user input +func ParseResourceIDInsensitively(input string) (*ResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(ResourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ResourceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ProviderName, ok = parsed.Parsed["providerName"]; !ok { + return nil, fmt.Errorf("the segment 'providerName' was not found in the resource id %q", input) + } + + if id.ParentResourcePath, ok = parsed.Parsed["parentResourcePath"]; !ok { + return nil, fmt.Errorf("the segment 'parentResourcePath' was not found in the resource id %q", input) + } + + if id.ResourceType, ok = parsed.Parsed["resourceType"]; !ok { + return nil, fmt.Errorf("the segment 'resourceType' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateResourceID checks that 'input' can be parsed as a Resource ID +func ValidateResourceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseResourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Resource ID +func (id ResourceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/%s/%s/%s/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProviderName, id.ParentResourcePath, id.ResourceType, id.ResourceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Resource ID +func (id ResourceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.UserSpecifiedSegment("providerName", "providerValue"), + resourceids.UserSpecifiedSegment("parentResourcePath", "parentResourcePathValue"), + resourceids.UserSpecifiedSegment("resourceType", "resourceTypeValue"), + resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), + } +} + +// String returns a human-readable description of this Resource ID +func (id ResourceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Provider Name: %q", id.ProviderName), + fmt.Sprintf("Parent Resource Path: %q", id.ParentResourcePath), + fmt.Sprintf("Resource Type: %q", id.ResourceType), + fmt.Sprintf("Resource Name: %q", id.ResourceName), + } + return fmt.Sprintf("Resource (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/id_resourcelock.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/id_resourcelock.go new file mode 100644 index 000000000000..38127b0a4ef2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/id_resourcelock.go @@ -0,0 +1,173 @@ +package managementlocks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = ResourceLockId{} + +// ResourceLockId is a struct representing the Resource ID for a Resource Lock +type ResourceLockId struct { + SubscriptionId string + ResourceGroupName string + ProviderName string + ParentResourcePath string + ResourceType string + ResourceName string + LockName string +} + +// NewResourceLockID returns a new ResourceLockId struct +func NewResourceLockID(subscriptionId string, resourceGroupName string, providerName string, parentResourcePath string, resourceType string, resourceName string, lockName string) ResourceLockId { + return ResourceLockId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProviderName: providerName, + ParentResourcePath: parentResourcePath, + ResourceType: resourceType, + ResourceName: resourceName, + LockName: lockName, + } +} + +// ParseResourceLockID parses 'input' into a ResourceLockId +func ParseResourceLockID(input string) (*ResourceLockId, error) { + parser := resourceids.NewParserFromResourceIdType(ResourceLockId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ResourceLockId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ProviderName, ok = parsed.Parsed["providerName"]; !ok { + return nil, fmt.Errorf("the segment 'providerName' was not found in the resource id %q", input) + } + + if id.ParentResourcePath, ok = parsed.Parsed["parentResourcePath"]; !ok { + return nil, fmt.Errorf("the segment 'parentResourcePath' was not found in the resource id %q", input) + } + + if id.ResourceType, ok = parsed.Parsed["resourceType"]; !ok { + return nil, fmt.Errorf("the segment 'resourceType' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + if id.LockName, ok = parsed.Parsed["lockName"]; !ok { + return nil, fmt.Errorf("the segment 'lockName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseResourceLockIDInsensitively parses 'input' case-insensitively into a ResourceLockId +// note: this method should only be used for API response data and not user input +func ParseResourceLockIDInsensitively(input string) (*ResourceLockId, error) { + parser := resourceids.NewParserFromResourceIdType(ResourceLockId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ResourceLockId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ProviderName, ok = parsed.Parsed["providerName"]; !ok { + return nil, fmt.Errorf("the segment 'providerName' was not found in the resource id %q", input) + } + + if id.ParentResourcePath, ok = parsed.Parsed["parentResourcePath"]; !ok { + return nil, fmt.Errorf("the segment 'parentResourcePath' was not found in the resource id %q", input) + } + + if id.ResourceType, ok = parsed.Parsed["resourceType"]; !ok { + return nil, fmt.Errorf("the segment 'resourceType' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + if id.LockName, ok = parsed.Parsed["lockName"]; !ok { + return nil, fmt.Errorf("the segment 'lockName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateResourceLockID checks that 'input' can be parsed as a Resource Lock ID +func ValidateResourceLockID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseResourceLockID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Resource Lock ID +func (id ResourceLockId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/%s/%s/%s/%s/providers/Microsoft.Authorization/locks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProviderName, id.ParentResourcePath, id.ResourceType, id.ResourceName, id.LockName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Resource Lock ID +func (id ResourceLockId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.UserSpecifiedSegment("providerName", "providerValue"), + resourceids.UserSpecifiedSegment("parentResourcePath", "parentResourcePathValue"), + resourceids.UserSpecifiedSegment("resourceType", "resourceTypeValue"), + resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), + resourceids.StaticSegment("staticProviders2", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticLocks", "locks", "locks"), + resourceids.UserSpecifiedSegment("lockName", "lockValue"), + } +} + +// String returns a human-readable description of this Resource Lock ID +func (id ResourceLockId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Provider Name: %q", id.ProviderName), + fmt.Sprintf("Parent Resource Path: %q", id.ParentResourcePath), + fmt.Sprintf("Resource Type: %q", id.ResourceType), + fmt.Sprintf("Resource Name: %q", id.ResourceName), + fmt.Sprintf("Lock Name: %q", id.LockName), + } + return fmt.Sprintf("Resource Lock (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/id_scopedlock.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/id_scopedlock.go new file mode 100644 index 000000000000..9bb87a3cbfce --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/id_scopedlock.go @@ -0,0 +1,110 @@ +package managementlocks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = ScopedLockId{} + +// ScopedLockId is a struct representing the Resource ID for a Scoped Lock +type ScopedLockId struct { + Scope string + LockName string +} + +// NewScopedLockID returns a new ScopedLockId struct +func NewScopedLockID(scope string, lockName string) ScopedLockId { + return ScopedLockId{ + Scope: scope, + LockName: lockName, + } +} + +// ParseScopedLockID parses 'input' into a ScopedLockId +func ParseScopedLockID(input string) (*ScopedLockId, error) { + parser := resourceids.NewParserFromResourceIdType(ScopedLockId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ScopedLockId{} + + if id.Scope, ok = parsed.Parsed["scope"]; !ok { + return nil, fmt.Errorf("the segment 'scope' was not found in the resource id %q", input) + } + + if id.LockName, ok = parsed.Parsed["lockName"]; !ok { + return nil, fmt.Errorf("the segment 'lockName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseScopedLockIDInsensitively parses 'input' case-insensitively into a ScopedLockId +// note: this method should only be used for API response data and not user input +func ParseScopedLockIDInsensitively(input string) (*ScopedLockId, error) { + parser := resourceids.NewParserFromResourceIdType(ScopedLockId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ScopedLockId{} + + if id.Scope, ok = parsed.Parsed["scope"]; !ok { + return nil, fmt.Errorf("the segment 'scope' was not found in the resource id %q", input) + } + + if id.LockName, ok = parsed.Parsed["lockName"]; !ok { + return nil, fmt.Errorf("the segment 'lockName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateScopedLockID checks that 'input' can be parsed as a Scoped Lock ID +func ValidateScopedLockID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseScopedLockID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Scoped Lock ID +func (id ScopedLockId) ID() string { + fmtString := "/%s/providers/Microsoft.Authorization/locks/%s" + return fmt.Sprintf(fmtString, strings.TrimPrefix(id.Scope, "/"), id.LockName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Scoped Lock ID +func (id ScopedLockId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.ScopeSegment("scope", "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticLocks", "locks", "locks"), + resourceids.UserSpecifiedSegment("lockName", "lockValue"), + } +} + +// String returns a human-readable description of this Scoped Lock ID +func (id ScopedLockId) String() string { + components := []string{ + fmt.Sprintf("Scope: %q", id.Scope), + fmt.Sprintf("Lock Name: %q", id.LockName), + } + return fmt.Sprintf("Scoped Lock (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_createorupdateatresourcegrouplevel_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_createorupdateatresourcegrouplevel_autorest.go new file mode 100644 index 000000000000..712fa4b40fa1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_createorupdateatresourcegrouplevel_autorest.go @@ -0,0 +1,69 @@ +package managementlocks + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateAtResourceGroupLevelOperationResponse struct { + HttpResponse *http.Response + Model *ManagementLockObject +} + +// CreateOrUpdateAtResourceGroupLevel ... +func (c ManagementLocksClient) CreateOrUpdateAtResourceGroupLevel(ctx context.Context, id ProviderLockId, input ManagementLockObject) (result CreateOrUpdateAtResourceGroupLevelOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdateAtResourceGroupLevel(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "CreateOrUpdateAtResourceGroupLevel", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "CreateOrUpdateAtResourceGroupLevel", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdateAtResourceGroupLevel(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "CreateOrUpdateAtResourceGroupLevel", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdateAtResourceGroupLevel prepares the CreateOrUpdateAtResourceGroupLevel request. +func (c ManagementLocksClient) preparerForCreateOrUpdateAtResourceGroupLevel(ctx context.Context, id ProviderLockId, input ManagementLockObject) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdateAtResourceGroupLevel handles the response to the CreateOrUpdateAtResourceGroupLevel request. The method always +// closes the http.Response Body. +func (c ManagementLocksClient) responderForCreateOrUpdateAtResourceGroupLevel(resp *http.Response) (result CreateOrUpdateAtResourceGroupLevelOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_createorupdateatresourcelevel_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_createorupdateatresourcelevel_autorest.go new file mode 100644 index 000000000000..d9a278311901 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_createorupdateatresourcelevel_autorest.go @@ -0,0 +1,69 @@ +package managementlocks + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateAtResourceLevelOperationResponse struct { + HttpResponse *http.Response + Model *ManagementLockObject +} + +// CreateOrUpdateAtResourceLevel ... +func (c ManagementLocksClient) CreateOrUpdateAtResourceLevel(ctx context.Context, id ResourceLockId, input ManagementLockObject) (result CreateOrUpdateAtResourceLevelOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdateAtResourceLevel(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "CreateOrUpdateAtResourceLevel", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "CreateOrUpdateAtResourceLevel", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdateAtResourceLevel(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "CreateOrUpdateAtResourceLevel", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdateAtResourceLevel prepares the CreateOrUpdateAtResourceLevel request. +func (c ManagementLocksClient) preparerForCreateOrUpdateAtResourceLevel(ctx context.Context, id ResourceLockId, input ManagementLockObject) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdateAtResourceLevel handles the response to the CreateOrUpdateAtResourceLevel request. The method always +// closes the http.Response Body. +func (c ManagementLocksClient) responderForCreateOrUpdateAtResourceLevel(resp *http.Response) (result CreateOrUpdateAtResourceLevelOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_createorupdateatsubscriptionlevel_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_createorupdateatsubscriptionlevel_autorest.go new file mode 100644 index 000000000000..2bc2fd857d6e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_createorupdateatsubscriptionlevel_autorest.go @@ -0,0 +1,69 @@ +package managementlocks + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateAtSubscriptionLevelOperationResponse struct { + HttpResponse *http.Response + Model *ManagementLockObject +} + +// CreateOrUpdateAtSubscriptionLevel ... +func (c ManagementLocksClient) CreateOrUpdateAtSubscriptionLevel(ctx context.Context, id LockId, input ManagementLockObject) (result CreateOrUpdateAtSubscriptionLevelOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdateAtSubscriptionLevel(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "CreateOrUpdateAtSubscriptionLevel", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "CreateOrUpdateAtSubscriptionLevel", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdateAtSubscriptionLevel(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "CreateOrUpdateAtSubscriptionLevel", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdateAtSubscriptionLevel prepares the CreateOrUpdateAtSubscriptionLevel request. +func (c ManagementLocksClient) preparerForCreateOrUpdateAtSubscriptionLevel(ctx context.Context, id LockId, input ManagementLockObject) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdateAtSubscriptionLevel handles the response to the CreateOrUpdateAtSubscriptionLevel request. The method always +// closes the http.Response Body. +func (c ManagementLocksClient) responderForCreateOrUpdateAtSubscriptionLevel(resp *http.Response) (result CreateOrUpdateAtSubscriptionLevelOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_createorupdatebyscope_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_createorupdatebyscope_autorest.go new file mode 100644 index 000000000000..9410b4e5f64b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_createorupdatebyscope_autorest.go @@ -0,0 +1,69 @@ +package managementlocks + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateByScopeOperationResponse struct { + HttpResponse *http.Response + Model *ManagementLockObject +} + +// CreateOrUpdateByScope ... +func (c ManagementLocksClient) CreateOrUpdateByScope(ctx context.Context, id ScopedLockId, input ManagementLockObject) (result CreateOrUpdateByScopeOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdateByScope(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "CreateOrUpdateByScope", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "CreateOrUpdateByScope", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdateByScope(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "CreateOrUpdateByScope", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdateByScope prepares the CreateOrUpdateByScope request. +func (c ManagementLocksClient) preparerForCreateOrUpdateByScope(ctx context.Context, id ScopedLockId, input ManagementLockObject) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdateByScope handles the response to the CreateOrUpdateByScope request. The method always +// closes the http.Response Body. +func (c ManagementLocksClient) responderForCreateOrUpdateByScope(resp *http.Response) (result CreateOrUpdateByScopeOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_deleteatresourcegrouplevel_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_deleteatresourcegrouplevel_autorest.go new file mode 100644 index 000000000000..5365e900bcf3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_deleteatresourcegrouplevel_autorest.go @@ -0,0 +1,66 @@ +package managementlocks + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteAtResourceGroupLevelOperationResponse struct { + HttpResponse *http.Response +} + +// DeleteAtResourceGroupLevel ... +func (c ManagementLocksClient) DeleteAtResourceGroupLevel(ctx context.Context, id ProviderLockId) (result DeleteAtResourceGroupLevelOperationResponse, err error) { + req, err := c.preparerForDeleteAtResourceGroupLevel(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "DeleteAtResourceGroupLevel", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "DeleteAtResourceGroupLevel", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDeleteAtResourceGroupLevel(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "DeleteAtResourceGroupLevel", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDeleteAtResourceGroupLevel prepares the DeleteAtResourceGroupLevel request. +func (c ManagementLocksClient) preparerForDeleteAtResourceGroupLevel(ctx context.Context, id ProviderLockId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDeleteAtResourceGroupLevel handles the response to the DeleteAtResourceGroupLevel request. The method always +// closes the http.Response Body. +func (c ManagementLocksClient) responderForDeleteAtResourceGroupLevel(resp *http.Response) (result DeleteAtResourceGroupLevelOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_deleteatresourcelevel_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_deleteatresourcelevel_autorest.go new file mode 100644 index 000000000000..b1648afd7032 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_deleteatresourcelevel_autorest.go @@ -0,0 +1,66 @@ +package managementlocks + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteAtResourceLevelOperationResponse struct { + HttpResponse *http.Response +} + +// DeleteAtResourceLevel ... +func (c ManagementLocksClient) DeleteAtResourceLevel(ctx context.Context, id ResourceLockId) (result DeleteAtResourceLevelOperationResponse, err error) { + req, err := c.preparerForDeleteAtResourceLevel(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "DeleteAtResourceLevel", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "DeleteAtResourceLevel", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDeleteAtResourceLevel(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "DeleteAtResourceLevel", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDeleteAtResourceLevel prepares the DeleteAtResourceLevel request. +func (c ManagementLocksClient) preparerForDeleteAtResourceLevel(ctx context.Context, id ResourceLockId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDeleteAtResourceLevel handles the response to the DeleteAtResourceLevel request. The method always +// closes the http.Response Body. +func (c ManagementLocksClient) responderForDeleteAtResourceLevel(resp *http.Response) (result DeleteAtResourceLevelOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_deleteatsubscriptionlevel_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_deleteatsubscriptionlevel_autorest.go new file mode 100644 index 000000000000..8324debca2ed --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_deleteatsubscriptionlevel_autorest.go @@ -0,0 +1,66 @@ +package managementlocks + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteAtSubscriptionLevelOperationResponse struct { + HttpResponse *http.Response +} + +// DeleteAtSubscriptionLevel ... +func (c ManagementLocksClient) DeleteAtSubscriptionLevel(ctx context.Context, id LockId) (result DeleteAtSubscriptionLevelOperationResponse, err error) { + req, err := c.preparerForDeleteAtSubscriptionLevel(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "DeleteAtSubscriptionLevel", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "DeleteAtSubscriptionLevel", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDeleteAtSubscriptionLevel(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "DeleteAtSubscriptionLevel", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDeleteAtSubscriptionLevel prepares the DeleteAtSubscriptionLevel request. +func (c ManagementLocksClient) preparerForDeleteAtSubscriptionLevel(ctx context.Context, id LockId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDeleteAtSubscriptionLevel handles the response to the DeleteAtSubscriptionLevel request. The method always +// closes the http.Response Body. +func (c ManagementLocksClient) responderForDeleteAtSubscriptionLevel(resp *http.Response) (result DeleteAtSubscriptionLevelOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_deletebyscope_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_deletebyscope_autorest.go new file mode 100644 index 000000000000..493345e25afd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_deletebyscope_autorest.go @@ -0,0 +1,66 @@ +package managementlocks + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteByScopeOperationResponse struct { + HttpResponse *http.Response +} + +// DeleteByScope ... +func (c ManagementLocksClient) DeleteByScope(ctx context.Context, id ScopedLockId) (result DeleteByScopeOperationResponse, err error) { + req, err := c.preparerForDeleteByScope(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "DeleteByScope", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "DeleteByScope", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDeleteByScope(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "DeleteByScope", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDeleteByScope prepares the DeleteByScope request. +func (c ManagementLocksClient) preparerForDeleteByScope(ctx context.Context, id ScopedLockId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDeleteByScope handles the response to the DeleteByScope request. The method always +// closes the http.Response Body. +func (c ManagementLocksClient) responderForDeleteByScope(resp *http.Response) (result DeleteByScopeOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_getatresourcegrouplevel_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_getatresourcegrouplevel_autorest.go new file mode 100644 index 000000000000..b23d946a2447 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_getatresourcegrouplevel_autorest.go @@ -0,0 +1,68 @@ +package managementlocks + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAtResourceGroupLevelOperationResponse struct { + HttpResponse *http.Response + Model *ManagementLockObject +} + +// GetAtResourceGroupLevel ... +func (c ManagementLocksClient) GetAtResourceGroupLevel(ctx context.Context, id ProviderLockId) (result GetAtResourceGroupLevelOperationResponse, err error) { + req, err := c.preparerForGetAtResourceGroupLevel(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "GetAtResourceGroupLevel", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "GetAtResourceGroupLevel", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGetAtResourceGroupLevel(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "GetAtResourceGroupLevel", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGetAtResourceGroupLevel prepares the GetAtResourceGroupLevel request. +func (c ManagementLocksClient) preparerForGetAtResourceGroupLevel(ctx context.Context, id ProviderLockId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGetAtResourceGroupLevel handles the response to the GetAtResourceGroupLevel request. The method always +// closes the http.Response Body. +func (c ManagementLocksClient) responderForGetAtResourceGroupLevel(resp *http.Response) (result GetAtResourceGroupLevelOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_getatresourcelevel_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_getatresourcelevel_autorest.go new file mode 100644 index 000000000000..f4b4ead5bf4d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_getatresourcelevel_autorest.go @@ -0,0 +1,68 @@ +package managementlocks + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAtResourceLevelOperationResponse struct { + HttpResponse *http.Response + Model *ManagementLockObject +} + +// GetAtResourceLevel ... +func (c ManagementLocksClient) GetAtResourceLevel(ctx context.Context, id ResourceLockId) (result GetAtResourceLevelOperationResponse, err error) { + req, err := c.preparerForGetAtResourceLevel(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "GetAtResourceLevel", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "GetAtResourceLevel", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGetAtResourceLevel(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "GetAtResourceLevel", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGetAtResourceLevel prepares the GetAtResourceLevel request. +func (c ManagementLocksClient) preparerForGetAtResourceLevel(ctx context.Context, id ResourceLockId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGetAtResourceLevel handles the response to the GetAtResourceLevel request. The method always +// closes the http.Response Body. +func (c ManagementLocksClient) responderForGetAtResourceLevel(resp *http.Response) (result GetAtResourceLevelOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_getatsubscriptionlevel_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_getatsubscriptionlevel_autorest.go new file mode 100644 index 000000000000..6b4aea0ab046 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_getatsubscriptionlevel_autorest.go @@ -0,0 +1,68 @@ +package managementlocks + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAtSubscriptionLevelOperationResponse struct { + HttpResponse *http.Response + Model *ManagementLockObject +} + +// GetAtSubscriptionLevel ... +func (c ManagementLocksClient) GetAtSubscriptionLevel(ctx context.Context, id LockId) (result GetAtSubscriptionLevelOperationResponse, err error) { + req, err := c.preparerForGetAtSubscriptionLevel(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "GetAtSubscriptionLevel", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "GetAtSubscriptionLevel", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGetAtSubscriptionLevel(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "GetAtSubscriptionLevel", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGetAtSubscriptionLevel prepares the GetAtSubscriptionLevel request. +func (c ManagementLocksClient) preparerForGetAtSubscriptionLevel(ctx context.Context, id LockId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGetAtSubscriptionLevel handles the response to the GetAtSubscriptionLevel request. The method always +// closes the http.Response Body. +func (c ManagementLocksClient) responderForGetAtSubscriptionLevel(resp *http.Response) (result GetAtSubscriptionLevelOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_getbyscope_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_getbyscope_autorest.go new file mode 100644 index 000000000000..6ab44235015b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_getbyscope_autorest.go @@ -0,0 +1,68 @@ +package managementlocks + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetByScopeOperationResponse struct { + HttpResponse *http.Response + Model *ManagementLockObject +} + +// GetByScope ... +func (c ManagementLocksClient) GetByScope(ctx context.Context, id ScopedLockId) (result GetByScopeOperationResponse, err error) { + req, err := c.preparerForGetByScope(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "GetByScope", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "GetByScope", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGetByScope(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "GetByScope", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGetByScope prepares the GetByScope request. +func (c ManagementLocksClient) preparerForGetByScope(ctx context.Context, id ScopedLockId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGetByScope handles the response to the GetByScope request. The method always +// closes the http.Response Body. +func (c ManagementLocksClient) responderForGetByScope(resp *http.Response) (result GetByScopeOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_listatresourcegrouplevel_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_listatresourcegrouplevel_autorest.go new file mode 100644 index 000000000000..c19f90ffa38e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_listatresourcegrouplevel_autorest.go @@ -0,0 +1,216 @@ +package managementlocks + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAtResourceGroupLevelOperationResponse struct { + HttpResponse *http.Response + Model *[]ManagementLockObject + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListAtResourceGroupLevelOperationResponse, error) +} + +type ListAtResourceGroupLevelCompleteResult struct { + Items []ManagementLockObject +} + +func (r ListAtResourceGroupLevelOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListAtResourceGroupLevelOperationResponse) LoadMore(ctx context.Context) (resp ListAtResourceGroupLevelOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListAtResourceGroupLevelOperationOptions struct { + Filter *string +} + +func DefaultListAtResourceGroupLevelOperationOptions() ListAtResourceGroupLevelOperationOptions { + return ListAtResourceGroupLevelOperationOptions{} +} + +func (o ListAtResourceGroupLevelOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListAtResourceGroupLevelOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// ListAtResourceGroupLevel ... +func (c ManagementLocksClient) ListAtResourceGroupLevel(ctx context.Context, id commonids.ResourceGroupId, options ListAtResourceGroupLevelOperationOptions) (resp ListAtResourceGroupLevelOperationResponse, err error) { + req, err := c.preparerForListAtResourceGroupLevel(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListAtResourceGroupLevel", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListAtResourceGroupLevel", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListAtResourceGroupLevel(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListAtResourceGroupLevel", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForListAtResourceGroupLevel prepares the ListAtResourceGroupLevel request. +func (c ManagementLocksClient) preparerForListAtResourceGroupLevel(ctx context.Context, id commonids.ResourceGroupId, options ListAtResourceGroupLevelOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Authorization/locks", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListAtResourceGroupLevelWithNextLink prepares the ListAtResourceGroupLevel request with the given nextLink token. +func (c ManagementLocksClient) preparerForListAtResourceGroupLevelWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListAtResourceGroupLevel handles the response to the ListAtResourceGroupLevel request. The method always +// closes the http.Response Body. +func (c ManagementLocksClient) responderForListAtResourceGroupLevel(resp *http.Response) (result ListAtResourceGroupLevelOperationResponse, err error) { + type page struct { + Values []ManagementLockObject `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListAtResourceGroupLevelOperationResponse, err error) { + req, err := c.preparerForListAtResourceGroupLevelWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListAtResourceGroupLevel", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListAtResourceGroupLevel", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListAtResourceGroupLevel(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListAtResourceGroupLevel", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListAtResourceGroupLevelComplete retrieves all of the results into a single object +func (c ManagementLocksClient) ListAtResourceGroupLevelComplete(ctx context.Context, id commonids.ResourceGroupId, options ListAtResourceGroupLevelOperationOptions) (ListAtResourceGroupLevelCompleteResult, error) { + return c.ListAtResourceGroupLevelCompleteMatchingPredicate(ctx, id, options, ManagementLockObjectOperationPredicate{}) +} + +// ListAtResourceGroupLevelCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c ManagementLocksClient) ListAtResourceGroupLevelCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListAtResourceGroupLevelOperationOptions, predicate ManagementLockObjectOperationPredicate) (resp ListAtResourceGroupLevelCompleteResult, err error) { + items := make([]ManagementLockObject, 0) + + page, err := c.ListAtResourceGroupLevel(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListAtResourceGroupLevelCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_listatresourcelevel_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_listatresourcelevel_autorest.go new file mode 100644 index 000000000000..674c46808874 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_listatresourcelevel_autorest.go @@ -0,0 +1,215 @@ +package managementlocks + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAtResourceLevelOperationResponse struct { + HttpResponse *http.Response + Model *[]ManagementLockObject + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListAtResourceLevelOperationResponse, error) +} + +type ListAtResourceLevelCompleteResult struct { + Items []ManagementLockObject +} + +func (r ListAtResourceLevelOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListAtResourceLevelOperationResponse) LoadMore(ctx context.Context) (resp ListAtResourceLevelOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListAtResourceLevelOperationOptions struct { + Filter *string +} + +func DefaultListAtResourceLevelOperationOptions() ListAtResourceLevelOperationOptions { + return ListAtResourceLevelOperationOptions{} +} + +func (o ListAtResourceLevelOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListAtResourceLevelOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// ListAtResourceLevel ... +func (c ManagementLocksClient) ListAtResourceLevel(ctx context.Context, id ResourceId, options ListAtResourceLevelOperationOptions) (resp ListAtResourceLevelOperationResponse, err error) { + req, err := c.preparerForListAtResourceLevel(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListAtResourceLevel", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListAtResourceLevel", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListAtResourceLevel(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListAtResourceLevel", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForListAtResourceLevel prepares the ListAtResourceLevel request. +func (c ManagementLocksClient) preparerForListAtResourceLevel(ctx context.Context, id ResourceId, options ListAtResourceLevelOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Authorization/locks", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListAtResourceLevelWithNextLink prepares the ListAtResourceLevel request with the given nextLink token. +func (c ManagementLocksClient) preparerForListAtResourceLevelWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListAtResourceLevel handles the response to the ListAtResourceLevel request. The method always +// closes the http.Response Body. +func (c ManagementLocksClient) responderForListAtResourceLevel(resp *http.Response) (result ListAtResourceLevelOperationResponse, err error) { + type page struct { + Values []ManagementLockObject `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListAtResourceLevelOperationResponse, err error) { + req, err := c.preparerForListAtResourceLevelWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListAtResourceLevel", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListAtResourceLevel", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListAtResourceLevel(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListAtResourceLevel", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListAtResourceLevelComplete retrieves all of the results into a single object +func (c ManagementLocksClient) ListAtResourceLevelComplete(ctx context.Context, id ResourceId, options ListAtResourceLevelOperationOptions) (ListAtResourceLevelCompleteResult, error) { + return c.ListAtResourceLevelCompleteMatchingPredicate(ctx, id, options, ManagementLockObjectOperationPredicate{}) +} + +// ListAtResourceLevelCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c ManagementLocksClient) ListAtResourceLevelCompleteMatchingPredicate(ctx context.Context, id ResourceId, options ListAtResourceLevelOperationOptions, predicate ManagementLockObjectOperationPredicate) (resp ListAtResourceLevelCompleteResult, err error) { + items := make([]ManagementLockObject, 0) + + page, err := c.ListAtResourceLevel(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListAtResourceLevelCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_listatsubscriptionlevel_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_listatsubscriptionlevel_autorest.go new file mode 100644 index 000000000000..b50549e36daf --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_listatsubscriptionlevel_autorest.go @@ -0,0 +1,216 @@ +package managementlocks + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAtSubscriptionLevelOperationResponse struct { + HttpResponse *http.Response + Model *[]ManagementLockObject + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListAtSubscriptionLevelOperationResponse, error) +} + +type ListAtSubscriptionLevelCompleteResult struct { + Items []ManagementLockObject +} + +func (r ListAtSubscriptionLevelOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListAtSubscriptionLevelOperationResponse) LoadMore(ctx context.Context) (resp ListAtSubscriptionLevelOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListAtSubscriptionLevelOperationOptions struct { + Filter *string +} + +func DefaultListAtSubscriptionLevelOperationOptions() ListAtSubscriptionLevelOperationOptions { + return ListAtSubscriptionLevelOperationOptions{} +} + +func (o ListAtSubscriptionLevelOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListAtSubscriptionLevelOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// ListAtSubscriptionLevel ... +func (c ManagementLocksClient) ListAtSubscriptionLevel(ctx context.Context, id commonids.SubscriptionId, options ListAtSubscriptionLevelOperationOptions) (resp ListAtSubscriptionLevelOperationResponse, err error) { + req, err := c.preparerForListAtSubscriptionLevel(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListAtSubscriptionLevel", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListAtSubscriptionLevel", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListAtSubscriptionLevel(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListAtSubscriptionLevel", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForListAtSubscriptionLevel prepares the ListAtSubscriptionLevel request. +func (c ManagementLocksClient) preparerForListAtSubscriptionLevel(ctx context.Context, id commonids.SubscriptionId, options ListAtSubscriptionLevelOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Authorization/locks", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListAtSubscriptionLevelWithNextLink prepares the ListAtSubscriptionLevel request with the given nextLink token. +func (c ManagementLocksClient) preparerForListAtSubscriptionLevelWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListAtSubscriptionLevel handles the response to the ListAtSubscriptionLevel request. The method always +// closes the http.Response Body. +func (c ManagementLocksClient) responderForListAtSubscriptionLevel(resp *http.Response) (result ListAtSubscriptionLevelOperationResponse, err error) { + type page struct { + Values []ManagementLockObject `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListAtSubscriptionLevelOperationResponse, err error) { + req, err := c.preparerForListAtSubscriptionLevelWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListAtSubscriptionLevel", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListAtSubscriptionLevel", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListAtSubscriptionLevel(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListAtSubscriptionLevel", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListAtSubscriptionLevelComplete retrieves all of the results into a single object +func (c ManagementLocksClient) ListAtSubscriptionLevelComplete(ctx context.Context, id commonids.SubscriptionId, options ListAtSubscriptionLevelOperationOptions) (ListAtSubscriptionLevelCompleteResult, error) { + return c.ListAtSubscriptionLevelCompleteMatchingPredicate(ctx, id, options, ManagementLockObjectOperationPredicate{}) +} + +// ListAtSubscriptionLevelCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c ManagementLocksClient) ListAtSubscriptionLevelCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListAtSubscriptionLevelOperationOptions, predicate ManagementLockObjectOperationPredicate) (resp ListAtSubscriptionLevelCompleteResult, err error) { + items := make([]ManagementLockObject, 0) + + page, err := c.ListAtSubscriptionLevel(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListAtSubscriptionLevelCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_listbyscope_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_listbyscope_autorest.go new file mode 100644 index 000000000000..83c088d91d7e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/method_listbyscope_autorest.go @@ -0,0 +1,216 @@ +package managementlocks + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByScopeOperationResponse struct { + HttpResponse *http.Response + Model *[]ManagementLockObject + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListByScopeOperationResponse, error) +} + +type ListByScopeCompleteResult struct { + Items []ManagementLockObject +} + +func (r ListByScopeOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListByScopeOperationResponse) LoadMore(ctx context.Context) (resp ListByScopeOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListByScopeOperationOptions struct { + Filter *string +} + +func DefaultListByScopeOperationOptions() ListByScopeOperationOptions { + return ListByScopeOperationOptions{} +} + +func (o ListByScopeOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListByScopeOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// ListByScope ... +func (c ManagementLocksClient) ListByScope(ctx context.Context, id commonids.ScopeId, options ListByScopeOperationOptions) (resp ListByScopeOperationResponse, err error) { + req, err := c.preparerForListByScope(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListByScope", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListByScope", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListByScope(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListByScope", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForListByScope prepares the ListByScope request. +func (c ManagementLocksClient) preparerForListByScope(ctx context.Context, id commonids.ScopeId, options ListByScopeOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Authorization/locks", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListByScopeWithNextLink prepares the ListByScope request with the given nextLink token. +func (c ManagementLocksClient) preparerForListByScopeWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListByScope handles the response to the ListByScope request. The method always +// closes the http.Response Body. +func (c ManagementLocksClient) responderForListByScope(resp *http.Response) (result ListByScopeOperationResponse, err error) { + type page struct { + Values []ManagementLockObject `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByScopeOperationResponse, err error) { + req, err := c.preparerForListByScopeWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListByScope", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListByScope", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByScope(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "managementlocks.ManagementLocksClient", "ListByScope", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListByScopeComplete retrieves all of the results into a single object +func (c ManagementLocksClient) ListByScopeComplete(ctx context.Context, id commonids.ScopeId, options ListByScopeOperationOptions) (ListByScopeCompleteResult, error) { + return c.ListByScopeCompleteMatchingPredicate(ctx, id, options, ManagementLockObjectOperationPredicate{}) +} + +// ListByScopeCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c ManagementLocksClient) ListByScopeCompleteMatchingPredicate(ctx context.Context, id commonids.ScopeId, options ListByScopeOperationOptions, predicate ManagementLockObjectOperationPredicate) (resp ListByScopeCompleteResult, err error) { + items := make([]ManagementLockObject, 0) + + page, err := c.ListByScope(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListByScopeCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/model_managementlockobject.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/model_managementlockobject.go new file mode 100644 index 000000000000..f2e419f69cc5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/model_managementlockobject.go @@ -0,0 +1,16 @@ +package managementlocks + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagementLockObject struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties ManagementLockProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/model_managementlockowner.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/model_managementlockowner.go new file mode 100644 index 000000000000..4e7b7388e30b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/model_managementlockowner.go @@ -0,0 +1,8 @@ +package managementlocks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagementLockOwner struct { + ApplicationId *string `json:"applicationId,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/model_managementlockproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/model_managementlockproperties.go new file mode 100644 index 000000000000..e1faa42ebb39 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/model_managementlockproperties.go @@ -0,0 +1,10 @@ +package managementlocks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagementLockProperties struct { + Level LockLevel `json:"level"` + Notes *string `json:"notes,omitempty"` + Owners *[]ManagementLockOwner `json:"owners,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/predicates.go new file mode 100644 index 000000000000..7ce2a4bb00a3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/predicates.go @@ -0,0 +1,24 @@ +package managementlocks + +type ManagementLockObjectOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ManagementLockObjectOperationPredicate) Matches(input ManagementLockObject) bool { + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/version.go new file mode 100644 index 000000000000..dcaf3863847e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks/version.go @@ -0,0 +1,12 @@ +package managementlocks + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2020-05-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managementlocks/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 13bb64c4ba6d..55de1efa257c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -50,7 +50,6 @@ github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2018-07-10/site github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2021-12-01/backup github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2015-12-01/features github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources -github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-06-01/resources @@ -459,6 +458,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/redisenterprise/2022-01-01/da github.com/hashicorp/go-azure-sdk/resource-manager/redisenterprise/2022-01-01/redisenterprise github.com/hashicorp/go-azure-sdk/resource-manager/relay/2017-04-01/hybridconnections github.com/hashicorp/go-azure-sdk/resource-manager/relay/2017-04-01/namespaces +github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-10-01/deploymentscripts github.com/hashicorp/go-azure-sdk/resource-manager/search/2020-03-13/adminkeys github.com/hashicorp/go-azure-sdk/resource-manager/search/2020-03-13/querykeys