From f63f3beecec0beecd0ebed6f66adff298a1c950b Mon Sep 17 00:00:00 2001 From: Justin Smith Date: Mon, 12 Aug 2019 11:47:25 -0600 Subject: [PATCH 01/10] Updating to Azure SDK API version 2018-09-01 --- .../data_source_builtin_role_definition.go | 2 +- azurerm/data_source_role_definition.go | 2 +- azurerm/resource_arm_role_assignment.go | 2 +- azurerm/resource_arm_role_definition.go | 2 +- .../authorization/classicadministrators.go | 151 ++ .../authorization/client.go | 51 + .../authorization/denyassignments.go | 699 ++++++++ .../authorization/globaladministrator.go | 108 ++ .../authorization/models.go | 1447 +++++++++++++++++ .../authorization/permissions.go | 275 ++++ .../provideroperationsmetadata.go | 235 +++ .../authorization/roleassignments.go | 1001 ++++++++++++ .../authorization/roledefinitions.go | 469 ++++++ .../authorization/version.go | 30 + vendor/modules.txt | 5 +- 15 files changed, 4473 insertions(+), 6 deletions(-) create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/classicadministrators.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/client.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/denyassignments.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/globaladministrator.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/models.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/permissions.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/provideroperationsmetadata.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/roleassignments.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/roledefinitions.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/version.go diff --git a/azurerm/data_source_builtin_role_definition.go b/azurerm/data_source_builtin_role_definition.go index 0c88f8a3fc30..982646d4f0be 100644 --- a/azurerm/data_source_builtin_role_definition.go +++ b/azurerm/data_source_builtin_role_definition.go @@ -3,7 +3,7 @@ package azurerm import ( "fmt" - "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization" + "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization" "github.com/hashicorp/terraform/helper/schema" ) diff --git a/azurerm/data_source_role_definition.go b/azurerm/data_source_role_definition.go index 192620b53d9b..a273252c93ef 100644 --- a/azurerm/data_source_role_definition.go +++ b/azurerm/data_source_role_definition.go @@ -3,7 +3,7 @@ package azurerm import ( "fmt" - "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization" + "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" "github.com/hashicorp/terraform/helper/schema" diff --git a/azurerm/resource_arm_role_assignment.go b/azurerm/resource_arm_role_assignment.go index 8747ee5a8a59..47eae31960da 100644 --- a/azurerm/resource_arm_role_assignment.go +++ b/azurerm/resource_arm_role_assignment.go @@ -10,7 +10,7 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/suppress" - "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization" + "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization" "github.com/hashicorp/go-uuid" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/schema" diff --git a/azurerm/resource_arm_role_definition.go b/azurerm/resource_arm_role_definition.go index d476cda32fc9..b39a431a637f 100644 --- a/azurerm/resource_arm_role_definition.go +++ b/azurerm/resource_arm_role_definition.go @@ -7,7 +7,7 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" - "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization" + "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization" "github.com/hashicorp/go-uuid" "github.com/hashicorp/terraform/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/classicadministrators.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/classicadministrators.go new file mode 100644 index 000000000000..c66bfbaf6024 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/classicadministrators.go @@ -0,0 +1,151 @@ +package authorization + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ClassicAdministratorsClient is the client for the ClassicAdministrators methods of the Authorization service. +type ClassicAdministratorsClient struct { + BaseClient +} + +// NewClassicAdministratorsClient creates an instance of the ClassicAdministratorsClient client. +func NewClassicAdministratorsClient(subscriptionID string) ClassicAdministratorsClient { + return NewClassicAdministratorsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewClassicAdministratorsClientWithBaseURI creates an instance of the ClassicAdministratorsClient client. +func NewClassicAdministratorsClientWithBaseURI(baseURI string, subscriptionID string) ClassicAdministratorsClient { + return ClassicAdministratorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List gets service administrator, account administrator, and co-administrators for the subscription. +func (client ClassicAdministratorsClient) List(ctx context.Context) (result ClassicAdministratorListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClassicAdministratorsClient.List") + defer func() { + sc := -1 + if result.calr.Response.Response != nil { + sc = result.calr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.calr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "List", resp, "Failure sending request") + return + } + + result.calr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ClassicAdministratorsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ClassicAdministratorsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ClassicAdministratorsClient) ListResponder(resp *http.Response) (result ClassicAdministratorListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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 ClassicAdministratorsClient) listNextResults(ctx context.Context, lastResults ClassicAdministratorListResult) (result ClassicAdministratorListResult, err error) { + req, err := lastResults.classicAdministratorListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "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, "authorization.ClassicAdministratorsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ClassicAdministratorsClient) ListComplete(ctx context.Context) (result ClassicAdministratorListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClassicAdministratorsClient.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/preview/authorization/mgmt/2018-09-01-preview/authorization/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/client.go new file mode 100644 index 000000000000..362420bdfa36 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/client.go @@ -0,0 +1,51 @@ +// Package authorization implements the Azure ARM Authorization service API version . +// +// +package authorization + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Authorization + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Authorization. +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. +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/preview/authorization/mgmt/2018-09-01-preview/authorization/denyassignments.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/denyassignments.go new file mode 100644 index 000000000000..5360189de936 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/denyassignments.go @@ -0,0 +1,699 @@ +package authorization + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DenyAssignmentsClient is the client for the DenyAssignments methods of the Authorization service. +type DenyAssignmentsClient struct { + BaseClient +} + +// NewDenyAssignmentsClient creates an instance of the DenyAssignmentsClient client. +func NewDenyAssignmentsClient(subscriptionID string) DenyAssignmentsClient { + return NewDenyAssignmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDenyAssignmentsClientWithBaseURI creates an instance of the DenyAssignmentsClient client. +func NewDenyAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) DenyAssignmentsClient { + return DenyAssignmentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the specified deny assignment. +// Parameters: +// scope - the scope of the deny assignment. +// denyAssignmentID - the ID of the deny assignment to get. +func (client DenyAssignmentsClient) Get(ctx context.Context, scope string, denyAssignmentID string) (result DenyAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DenyAssignmentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, scope, denyAssignmentID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DenyAssignmentsClient) GetPreparer(ctx context.Context, scope string, denyAssignmentID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "denyAssignmentId": autorest.Encode("path", denyAssignmentID), + "scope": scope, + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DenyAssignmentsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DenyAssignmentsClient) GetResponder(resp *http.Response) (result DenyAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByID gets a deny assignment by ID. +// Parameters: +// denyAssignmentID - the fully qualified deny assignment ID. For example, use the format, +// /subscriptions/{guid}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId} for subscription +// level deny assignments, or /providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId} for tenant +// level deny assignments. +func (client DenyAssignmentsClient) GetByID(ctx context.Context, denyAssignmentID string) (result DenyAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DenyAssignmentsClient.GetByID") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByIDPreparer(ctx, denyAssignmentID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "GetByID", nil, "Failure preparing request") + return + } + + resp, err := client.GetByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "GetByID", resp, "Failure sending request") + return + } + + result, err = client.GetByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "GetByID", resp, "Failure responding to request") + } + + return +} + +// GetByIDPreparer prepares the GetByID request. +func (client DenyAssignmentsClient) GetByIDPreparer(ctx context.Context, denyAssignmentID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "denyAssignmentId": denyAssignmentID, + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{denyAssignmentId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByIDSender sends the GetByID request. The method will close the +// http.Response Body if it receives an error. +func (client DenyAssignmentsClient) GetByIDSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetByIDResponder handles the response to the GetByID request. The method always +// closes the http.Response Body. +func (client DenyAssignmentsClient) GetByIDResponder(resp *http.Response) (result DenyAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets all deny assignments for the subscription. +// Parameters: +// filter - the filter to apply on the operation. Use $filter=atScope() to return all deny assignments at or +// above the scope. Use $filter=denyAssignmentName eq '{name}' to search deny assignments by name at specified +// scope. Use $filter=principalId eq '{id}' to return all deny assignments at, above and below the scope for +// the specified principal. Use $filter=gdprExportPrincipalId eq '{id}' to return all deny assignments at, +// above and below the scope for the specified principal. This filter is different from the principalId filter +// as it returns not only those deny assignments that contain the specified principal is the Principals list +// but also those deny assignments that contain the specified principal is the ExcludePrincipals list. +// Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description +// properties are returned. +func (client DenyAssignmentsClient) List(ctx context.Context, filter string) (result DenyAssignmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DenyAssignmentsClient.List") + defer func() { + sc := -1 + if result.dalr.Response.Response != nil { + sc = result.dalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.dalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "List", resp, "Failure sending request") + return + } + + result.dalr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client DenyAssignmentsClient) ListPreparer(ctx context.Context, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-07-01-preview" + 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/denyAssignments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client DenyAssignmentsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client DenyAssignmentsClient) ListResponder(resp *http.Response) (result DenyAssignmentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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 DenyAssignmentsClient) listNextResults(ctx context.Context, lastResults DenyAssignmentListResult) (result DenyAssignmentListResult, err error) { + req, err := lastResults.denyAssignmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "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, "authorization.DenyAssignmentsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client DenyAssignmentsClient) ListComplete(ctx context.Context, filter string) (result DenyAssignmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DenyAssignmentsClient.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, filter) + return +} + +// ListForResource gets deny assignments for a resource. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceProviderNamespace - the namespace of the resource provider. +// parentResourcePath - the parent resource identity. +// resourceType - the resource type of the resource. +// resourceName - the name of the resource to get deny assignments for. +// filter - the filter to apply on the operation. Use $filter=atScope() to return all deny assignments at or +// above the scope. Use $filter=denyAssignmentName eq '{name}' to search deny assignments by name at specified +// scope. Use $filter=principalId eq '{id}' to return all deny assignments at, above and below the scope for +// the specified principal. Use $filter=gdprExportPrincipalId eq '{id}' to return all deny assignments at, +// above and below the scope for the specified principal. This filter is different from the principalId filter +// as it returns not only those deny assignments that contain the specified principal is the Principals list +// but also those deny assignments that contain the specified principal is the ExcludePrincipals list. +// Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description +// properties are returned. +func (client DenyAssignmentsClient) ListForResource(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (result DenyAssignmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DenyAssignmentsClient.ListForResource") + defer func() { + sc := -1 + if result.dalr.Response.Response != nil { + sc = result.dalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listForResourceNextResults + req, err := client.ListForResourcePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "ListForResource", nil, "Failure preparing request") + return + } + + resp, err := client.ListForResourceSender(req) + if err != nil { + result.dalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "ListForResource", resp, "Failure sending request") + return + } + + result.dalr, err = client.ListForResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "ListForResource", resp, "Failure responding to request") + } + + return +} + +// ListForResourcePreparer prepares the ListForResource request. +func (client DenyAssignmentsClient) ListForResourcePreparer(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 = "2018-07-01-preview" + 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/denyAssignments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListForResourceSender sends the ListForResource request. The method will close the +// http.Response Body if it receives an error. +func (client DenyAssignmentsClient) ListForResourceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListForResourceResponder handles the response to the ListForResource request. The method always +// closes the http.Response Body. +func (client DenyAssignmentsClient) ListForResourceResponder(resp *http.Response) (result DenyAssignmentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listForResourceNextResults retrieves the next set of results, if any. +func (client DenyAssignmentsClient) listForResourceNextResults(ctx context.Context, lastResults DenyAssignmentListResult) (result DenyAssignmentListResult, err error) { + req, err := lastResults.denyAssignmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "listForResourceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListForResourceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "listForResourceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListForResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "listForResourceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListForResourceComplete enumerates all values, automatically crossing page boundaries as required. +func (client DenyAssignmentsClient) ListForResourceComplete(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (result DenyAssignmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DenyAssignmentsClient.ListForResource") + 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.ListForResource(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter) + return +} + +// ListForResourceGroup gets deny assignments for a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +// filter - the filter to apply on the operation. Use $filter=atScope() to return all deny assignments at or +// above the scope. Use $filter=denyAssignmentName eq '{name}' to search deny assignments by name at specified +// scope. Use $filter=principalId eq '{id}' to return all deny assignments at, above and below the scope for +// the specified principal. Use $filter=gdprExportPrincipalId eq '{id}' to return all deny assignments at, +// above and below the scope for the specified principal. This filter is different from the principalId filter +// as it returns not only those deny assignments that contain the specified principal is the Principals list +// but also those deny assignments that contain the specified principal is the ExcludePrincipals list. +// Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description +// properties are returned. +func (client DenyAssignmentsClient) ListForResourceGroup(ctx context.Context, resourceGroupName string, filter string) (result DenyAssignmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DenyAssignmentsClient.ListForResourceGroup") + defer func() { + sc := -1 + if result.dalr.Response.Response != nil { + sc = result.dalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listForResourceGroupNextResults + req, err := client.ListForResourceGroupPreparer(ctx, resourceGroupName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "ListForResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListForResourceGroupSender(req) + if err != nil { + result.dalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "ListForResourceGroup", resp, "Failure sending request") + return + } + + result.dalr, err = client.ListForResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "ListForResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListForResourceGroupPreparer prepares the ListForResourceGroup request. +func (client DenyAssignmentsClient) ListForResourceGroupPreparer(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 = "2018-07-01-preview" + 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/denyAssignments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListForResourceGroupSender sends the ListForResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client DenyAssignmentsClient) ListForResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListForResourceGroupResponder handles the response to the ListForResourceGroup request. The method always +// closes the http.Response Body. +func (client DenyAssignmentsClient) ListForResourceGroupResponder(resp *http.Response) (result DenyAssignmentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listForResourceGroupNextResults retrieves the next set of results, if any. +func (client DenyAssignmentsClient) listForResourceGroupNextResults(ctx context.Context, lastResults DenyAssignmentListResult) (result DenyAssignmentListResult, err error) { + req, err := lastResults.denyAssignmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "listForResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListForResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "listForResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListForResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "listForResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListForResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client DenyAssignmentsClient) ListForResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string) (result DenyAssignmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DenyAssignmentsClient.ListForResourceGroup") + 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.ListForResourceGroup(ctx, resourceGroupName, filter) + return +} + +// ListForScope gets deny assignments for a scope. +// Parameters: +// scope - the scope of the deny assignments. +// filter - the filter to apply on the operation. Use $filter=atScope() to return all deny assignments at or +// above the scope. Use $filter=denyAssignmentName eq '{name}' to search deny assignments by name at specified +// scope. Use $filter=principalId eq '{id}' to return all deny assignments at, above and below the scope for +// the specified principal. Use $filter=gdprExportPrincipalId eq '{id}' to return all deny assignments at, +// above and below the scope for the specified principal. This filter is different from the principalId filter +// as it returns not only those deny assignments that contain the specified principal is the Principals list +// but also those deny assignments that contain the specified principal is the ExcludePrincipals list. +// Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description +// properties are returned. +func (client DenyAssignmentsClient) ListForScope(ctx context.Context, scope string, filter string) (result DenyAssignmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DenyAssignmentsClient.ListForScope") + defer func() { + sc := -1 + if result.dalr.Response.Response != nil { + sc = result.dalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listForScopeNextResults + req, err := client.ListForScopePreparer(ctx, scope, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "ListForScope", nil, "Failure preparing request") + return + } + + resp, err := client.ListForScopeSender(req) + if err != nil { + result.dalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "ListForScope", resp, "Failure sending request") + return + } + + result.dalr, err = client.ListForScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "ListForScope", resp, "Failure responding to request") + } + + return +} + +// ListForScopePreparer prepares the ListForScope request. +func (client DenyAssignmentsClient) ListForScopePreparer(ctx context.Context, scope string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2018-07-01-preview" + 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/denyAssignments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListForScopeSender sends the ListForScope request. The method will close the +// http.Response Body if it receives an error. +func (client DenyAssignmentsClient) ListForScopeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListForScopeResponder handles the response to the ListForScope request. The method always +// closes the http.Response Body. +func (client DenyAssignmentsClient) ListForScopeResponder(resp *http.Response) (result DenyAssignmentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listForScopeNextResults retrieves the next set of results, if any. +func (client DenyAssignmentsClient) listForScopeNextResults(ctx context.Context, lastResults DenyAssignmentListResult) (result DenyAssignmentListResult, err error) { + req, err := lastResults.denyAssignmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "listForScopeNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListForScopeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "listForScopeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListForScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.DenyAssignmentsClient", "listForScopeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListForScopeComplete enumerates all values, automatically crossing page boundaries as required. +func (client DenyAssignmentsClient) ListForScopeComplete(ctx context.Context, scope string, filter string) (result DenyAssignmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DenyAssignmentsClient.ListForScope") + 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.ListForScope(ctx, scope, filter) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/globaladministrator.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/globaladministrator.go new file mode 100644 index 000000000000..d9e0167cdbcc --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/globaladministrator.go @@ -0,0 +1,108 @@ +package authorization + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// GlobalAdministratorClient is the client for the GlobalAdministrator methods of the Authorization service. +type GlobalAdministratorClient struct { + BaseClient +} + +// NewGlobalAdministratorClient creates an instance of the GlobalAdministratorClient client. +func NewGlobalAdministratorClient(subscriptionID string) GlobalAdministratorClient { + return NewGlobalAdministratorClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGlobalAdministratorClientWithBaseURI creates an instance of the GlobalAdministratorClient client. +func NewGlobalAdministratorClientWithBaseURI(baseURI string, subscriptionID string) GlobalAdministratorClient { + return GlobalAdministratorClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ElevateAccess elevates access for a Global Administrator. +func (client GlobalAdministratorClient) ElevateAccess(ctx context.Context) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GlobalAdministratorClient.ElevateAccess") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ElevateAccessPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.GlobalAdministratorClient", "ElevateAccess", nil, "Failure preparing request") + return + } + + resp, err := client.ElevateAccessSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "authorization.GlobalAdministratorClient", "ElevateAccess", resp, "Failure sending request") + return + } + + result, err = client.ElevateAccessResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.GlobalAdministratorClient", "ElevateAccess", resp, "Failure responding to request") + } + + return +} + +// ElevateAccessPreparer prepares the ElevateAccess request. +func (client GlobalAdministratorClient) ElevateAccessPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2015-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Authorization/elevateAccess"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ElevateAccessSender sends the ElevateAccess request. The method will close the +// http.Response Body if it receives an error. +func (client GlobalAdministratorClient) ElevateAccessSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ElevateAccessResponder handles the response to the ElevateAccess request. The method always +// closes the http.Response Body. +func (client GlobalAdministratorClient) ElevateAccessResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/models.go new file mode 100644 index 000000000000..3be0fe4fb4e2 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/models.go @@ -0,0 +1,1447 @@ +package authorization + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/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/preview/authorization/mgmt/2018-09-01-preview/authorization" + +// PrincipalType enumerates the values for principal type. +type PrincipalType string + +const ( + // Application ... + Application PrincipalType = "Application" + // DirectoryObjectOrGroup ... + DirectoryObjectOrGroup PrincipalType = "DirectoryObjectOrGroup" + // DirectoryRoleTemplate ... + DirectoryRoleTemplate PrincipalType = "DirectoryRoleTemplate" + // Everyone ... + Everyone PrincipalType = "Everyone" + // ForeignGroup ... + ForeignGroup PrincipalType = "ForeignGroup" + // Group ... + Group PrincipalType = "Group" + // MSI ... + MSI PrincipalType = "MSI" + // ServicePrincipal ... + ServicePrincipal PrincipalType = "ServicePrincipal" + // Unknown ... + Unknown PrincipalType = "Unknown" + // User ... + User PrincipalType = "User" +) + +// PossiblePrincipalTypeValues returns an array of possible values for the PrincipalType const type. +func PossiblePrincipalTypeValues() []PrincipalType { + return []PrincipalType{Application, DirectoryObjectOrGroup, DirectoryRoleTemplate, Everyone, ForeignGroup, Group, MSI, ServicePrincipal, Unknown, User} +} + +// ClassicAdministrator classic Administrators +type ClassicAdministrator struct { + // ID - The ID of the administrator. + ID *string `json:"id,omitempty"` + // Name - The name of the administrator. + Name *string `json:"name,omitempty"` + // Type - The type of the administrator. + Type *string `json:"type,omitempty"` + // ClassicAdministratorProperties - Properties for the classic administrator. + *ClassicAdministratorProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ClassicAdministrator. +func (ca ClassicAdministrator) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ca.ID != nil { + objectMap["id"] = ca.ID + } + if ca.Name != nil { + objectMap["name"] = ca.Name + } + if ca.Type != nil { + objectMap["type"] = ca.Type + } + if ca.ClassicAdministratorProperties != nil { + objectMap["properties"] = ca.ClassicAdministratorProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ClassicAdministrator struct. +func (ca *ClassicAdministrator) 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 "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ca.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ca.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ca.Type = &typeVar + } + case "properties": + if v != nil { + var classicAdministratorProperties ClassicAdministratorProperties + err = json.Unmarshal(*v, &classicAdministratorProperties) + if err != nil { + return err + } + ca.ClassicAdministratorProperties = &classicAdministratorProperties + } + } + } + + return nil +} + +// ClassicAdministratorListResult classicAdministrator list result information. +type ClassicAdministratorListResult struct { + autorest.Response `json:"-"` + // Value - An array of administrators. + Value *[]ClassicAdministrator `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ClassicAdministratorListResultIterator provides access to a complete listing of ClassicAdministrator +// values. +type ClassicAdministratorListResultIterator struct { + i int + page ClassicAdministratorListResultPage +} + +// 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 *ClassicAdministratorListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClassicAdministratorListResultIterator.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 *ClassicAdministratorListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ClassicAdministratorListResultIterator) 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 ClassicAdministratorListResultIterator) Response() ClassicAdministratorListResult { + 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 ClassicAdministratorListResultIterator) Value() ClassicAdministrator { + if !iter.page.NotDone() { + return ClassicAdministrator{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ClassicAdministratorListResultIterator type. +func NewClassicAdministratorListResultIterator(page ClassicAdministratorListResultPage) ClassicAdministratorListResultIterator { + return ClassicAdministratorListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (calr ClassicAdministratorListResult) IsEmpty() bool { + return calr.Value == nil || len(*calr.Value) == 0 +} + +// classicAdministratorListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (calr ClassicAdministratorListResult) classicAdministratorListResultPreparer(ctx context.Context) (*http.Request, error) { + if calr.NextLink == nil || len(to.String(calr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(calr.NextLink))) +} + +// ClassicAdministratorListResultPage contains a page of ClassicAdministrator values. +type ClassicAdministratorListResultPage struct { + fn func(context.Context, ClassicAdministratorListResult) (ClassicAdministratorListResult, error) + calr ClassicAdministratorListResult +} + +// 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 *ClassicAdministratorListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClassicAdministratorListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.calr) + if err != nil { + return err + } + page.calr = next + 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 *ClassicAdministratorListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ClassicAdministratorListResultPage) NotDone() bool { + return !page.calr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ClassicAdministratorListResultPage) Response() ClassicAdministratorListResult { + return page.calr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ClassicAdministratorListResultPage) Values() []ClassicAdministrator { + if page.calr.IsEmpty() { + return nil + } + return *page.calr.Value +} + +// Creates a new instance of the ClassicAdministratorListResultPage type. +func NewClassicAdministratorListResultPage(getNextPage func(context.Context, ClassicAdministratorListResult) (ClassicAdministratorListResult, error)) ClassicAdministratorListResultPage { + return ClassicAdministratorListResultPage{fn: getNextPage} +} + +// ClassicAdministratorProperties classic Administrator properties. +type ClassicAdministratorProperties struct { + // EmailAddress - The email address of the administrator. + EmailAddress *string `json:"emailAddress,omitempty"` + // Role - The role of the administrator. + Role *string `json:"role,omitempty"` +} + +// DenyAssignment deny Assignment +type DenyAssignment struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The deny assignment ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The deny assignment name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The deny assignment type. + Type *string `json:"type,omitempty"` + // DenyAssignmentProperties - Deny assignment properties. + *DenyAssignmentProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for DenyAssignment. +func (da DenyAssignment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if da.DenyAssignmentProperties != nil { + objectMap["properties"] = da.DenyAssignmentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DenyAssignment struct. +func (da *DenyAssignment) 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 "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + da.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + da.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + da.Type = &typeVar + } + case "properties": + if v != nil { + var denyAssignmentProperties DenyAssignmentProperties + err = json.Unmarshal(*v, &denyAssignmentProperties) + if err != nil { + return err + } + da.DenyAssignmentProperties = &denyAssignmentProperties + } + } + } + + return nil +} + +// DenyAssignmentFilter deny Assignments filter +type DenyAssignmentFilter struct { + // DenyAssignmentName - Return deny assignment with specified name. + DenyAssignmentName *string `json:"denyAssignmentName,omitempty"` + // PrincipalID - Return all deny assignments where the specified principal is listed in the principals list of deny assignments. + PrincipalID *string `json:"principalId,omitempty"` + // GdprExportPrincipalID - Return all deny assignments where the specified principal is listed either in the principals list or exclude principals list of deny assignments. + GdprExportPrincipalID *string `json:"gdprExportPrincipalId,omitempty"` +} + +// DenyAssignmentListResult deny assignment list operation result. +type DenyAssignmentListResult struct { + autorest.Response `json:"-"` + // Value - Deny assignment list. + Value *[]DenyAssignment `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// DenyAssignmentListResultIterator provides access to a complete listing of DenyAssignment values. +type DenyAssignmentListResultIterator struct { + i int + page DenyAssignmentListResultPage +} + +// 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 *DenyAssignmentListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DenyAssignmentListResultIterator.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 *DenyAssignmentListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DenyAssignmentListResultIterator) 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 DenyAssignmentListResultIterator) Response() DenyAssignmentListResult { + 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 DenyAssignmentListResultIterator) Value() DenyAssignment { + if !iter.page.NotDone() { + return DenyAssignment{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DenyAssignmentListResultIterator type. +func NewDenyAssignmentListResultIterator(page DenyAssignmentListResultPage) DenyAssignmentListResultIterator { + return DenyAssignmentListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dalr DenyAssignmentListResult) IsEmpty() bool { + return dalr.Value == nil || len(*dalr.Value) == 0 +} + +// denyAssignmentListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dalr DenyAssignmentListResult) denyAssignmentListResultPreparer(ctx context.Context) (*http.Request, error) { + if dalr.NextLink == nil || len(to.String(dalr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dalr.NextLink))) +} + +// DenyAssignmentListResultPage contains a page of DenyAssignment values. +type DenyAssignmentListResultPage struct { + fn func(context.Context, DenyAssignmentListResult) (DenyAssignmentListResult, error) + dalr DenyAssignmentListResult +} + +// 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 *DenyAssignmentListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DenyAssignmentListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.dalr) + if err != nil { + return err + } + page.dalr = next + 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 *DenyAssignmentListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DenyAssignmentListResultPage) NotDone() bool { + return !page.dalr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DenyAssignmentListResultPage) Response() DenyAssignmentListResult { + return page.dalr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DenyAssignmentListResultPage) Values() []DenyAssignment { + if page.dalr.IsEmpty() { + return nil + } + return *page.dalr.Value +} + +// Creates a new instance of the DenyAssignmentListResultPage type. +func NewDenyAssignmentListResultPage(getNextPage func(context.Context, DenyAssignmentListResult) (DenyAssignmentListResult, error)) DenyAssignmentListResultPage { + return DenyAssignmentListResultPage{fn: getNextPage} +} + +// DenyAssignmentPermission deny assignment permissions. +type DenyAssignmentPermission struct { + // Actions - Actions to which the deny assignment does not grant access. + Actions *[]string `json:"actions,omitempty"` + // NotActions - Actions to exclude from that the deny assignment does not grant access. + NotActions *[]string `json:"notActions,omitempty"` + // DataActions - Data actions to which the deny assignment does not grant access. + DataActions *[]string `json:"dataActions,omitempty"` + // NotDataActions - Data actions to exclude from that the deny assignment does not grant access. + NotDataActions *[]string `json:"notDataActions,omitempty"` +} + +// DenyAssignmentProperties deny assignment properties. +type DenyAssignmentProperties struct { + // DenyAssignmentName - The display name of the deny assignment. + DenyAssignmentName *string `json:"denyAssignmentName,omitempty"` + // Description - The description of the deny assignment. + Description *string `json:"description,omitempty"` + // Permissions - An array of permissions that are denied by the deny assignment. + Permissions *[]DenyAssignmentPermission `json:"permissions,omitempty"` + // Scope - The deny assignment scope. + Scope *string `json:"scope,omitempty"` + // DoNotApplyToChildScopes - Determines if the deny assignment applies to child scopes. Default value is false. + DoNotApplyToChildScopes *bool `json:"doNotApplyToChildScopes,omitempty"` + // Principals - Array of principals to which the deny assignment applies. + Principals *[]Principal `json:"principals,omitempty"` + // ExcludePrincipals - Array of principals to which the deny assignment does not apply. + ExcludePrincipals *[]Principal `json:"excludePrincipals,omitempty"` + // IsSystemProtected - Specifies whether this deny assignment was created by Azure and cannot be edited or deleted. + IsSystemProtected *bool `json:"isSystemProtected,omitempty"` +} + +// Permission role definition permissions. +type Permission struct { + // Actions - Allowed actions. + Actions *[]string `json:"actions,omitempty"` + // NotActions - Denied actions. + NotActions *[]string `json:"notActions,omitempty"` + // DataActions - Allowed Data actions. + DataActions *[]string `json:"dataActions,omitempty"` + // NotDataActions - Denied Data actions. + NotDataActions *[]string `json:"notDataActions,omitempty"` +} + +// PermissionGetResult permissions information. +type PermissionGetResult struct { + autorest.Response `json:"-"` + // Value - An array of permissions. + Value *[]Permission `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// PermissionGetResultIterator provides access to a complete listing of Permission values. +type PermissionGetResultIterator struct { + i int + page PermissionGetResultPage +} + +// 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 *PermissionGetResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PermissionGetResultIterator.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 *PermissionGetResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PermissionGetResultIterator) 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 PermissionGetResultIterator) Response() PermissionGetResult { + 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 PermissionGetResultIterator) Value() Permission { + if !iter.page.NotDone() { + return Permission{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PermissionGetResultIterator type. +func NewPermissionGetResultIterator(page PermissionGetResultPage) PermissionGetResultIterator { + return PermissionGetResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (pgr PermissionGetResult) IsEmpty() bool { + return pgr.Value == nil || len(*pgr.Value) == 0 +} + +// permissionGetResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (pgr PermissionGetResult) permissionGetResultPreparer(ctx context.Context) (*http.Request, error) { + if pgr.NextLink == nil || len(to.String(pgr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(pgr.NextLink))) +} + +// PermissionGetResultPage contains a page of Permission values. +type PermissionGetResultPage struct { + fn func(context.Context, PermissionGetResult) (PermissionGetResult, error) + pgr PermissionGetResult +} + +// 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 *PermissionGetResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PermissionGetResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.pgr) + if err != nil { + return err + } + page.pgr = next + 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 *PermissionGetResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PermissionGetResultPage) NotDone() bool { + return !page.pgr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PermissionGetResultPage) Response() PermissionGetResult { + return page.pgr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PermissionGetResultPage) Values() []Permission { + if page.pgr.IsEmpty() { + return nil + } + return *page.pgr.Value +} + +// Creates a new instance of the PermissionGetResultPage type. +func NewPermissionGetResultPage(getNextPage func(context.Context, PermissionGetResult) (PermissionGetResult, error)) PermissionGetResultPage { + return PermissionGetResultPage{fn: getNextPage} +} + +// Principal deny assignment principal. +type Principal struct { + // ID - READ-ONLY; Object ID of the Azure AD principal (user, group, or service principal) to which the deny assignment applies. An empty guid '00000000-0000-0000-0000-000000000000' as principal id and principal type as 'Everyone' represents all users, groups and service principals. + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; Type of object represented by principal id (user, group, or service principal). An empty guid '00000000-0000-0000-0000-000000000000' as principal id and principal type as 'Everyone' represents all users, groups and service principals. + Type *string `json:"type,omitempty"` +} + +// ProviderOperation operation +type ProviderOperation struct { + // Name - The operation name. + Name *string `json:"name,omitempty"` + // DisplayName - The operation display name. + DisplayName *string `json:"displayName,omitempty"` + // Description - The operation description. + Description *string `json:"description,omitempty"` + // Origin - The operation origin. + Origin *string `json:"origin,omitempty"` + // Properties - The operation properties. + Properties interface{} `json:"properties,omitempty"` + // IsDataAction - The dataAction flag to specify the operation type. + IsDataAction *bool `json:"isDataAction,omitempty"` +} + +// ProviderOperationsMetadata provider Operations metadata +type ProviderOperationsMetadata struct { + autorest.Response `json:"-"` + // ID - The provider id. + ID *string `json:"id,omitempty"` + // Name - The provider name. + Name *string `json:"name,omitempty"` + // Type - The provider type. + Type *string `json:"type,omitempty"` + // DisplayName - The provider display name. + DisplayName *string `json:"displayName,omitempty"` + // ResourceTypes - The provider resource types + ResourceTypes *[]ResourceType `json:"resourceTypes,omitempty"` + // Operations - The provider operations. + Operations *[]ProviderOperation `json:"operations,omitempty"` +} + +// ProviderOperationsMetadataListResult provider operations metadata list +type ProviderOperationsMetadataListResult struct { + autorest.Response `json:"-"` + // Value - The list of providers. + Value *[]ProviderOperationsMetadata `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ProviderOperationsMetadataListResultIterator provides access to a complete listing of +// ProviderOperationsMetadata values. +type ProviderOperationsMetadataListResultIterator struct { + i int + page ProviderOperationsMetadataListResultPage +} + +// 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 *ProviderOperationsMetadataListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProviderOperationsMetadataListResultIterator.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 *ProviderOperationsMetadataListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ProviderOperationsMetadataListResultIterator) 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 ProviderOperationsMetadataListResultIterator) Response() ProviderOperationsMetadataListResult { + 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 ProviderOperationsMetadataListResultIterator) Value() ProviderOperationsMetadata { + if !iter.page.NotDone() { + return ProviderOperationsMetadata{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ProviderOperationsMetadataListResultIterator type. +func NewProviderOperationsMetadataListResultIterator(page ProviderOperationsMetadataListResultPage) ProviderOperationsMetadataListResultIterator { + return ProviderOperationsMetadataListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (pomlr ProviderOperationsMetadataListResult) IsEmpty() bool { + return pomlr.Value == nil || len(*pomlr.Value) == 0 +} + +// providerOperationsMetadataListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (pomlr ProviderOperationsMetadataListResult) providerOperationsMetadataListResultPreparer(ctx context.Context) (*http.Request, error) { + if pomlr.NextLink == nil || len(to.String(pomlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(pomlr.NextLink))) +} + +// ProviderOperationsMetadataListResultPage contains a page of ProviderOperationsMetadata values. +type ProviderOperationsMetadataListResultPage struct { + fn func(context.Context, ProviderOperationsMetadataListResult) (ProviderOperationsMetadataListResult, error) + pomlr ProviderOperationsMetadataListResult +} + +// 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 *ProviderOperationsMetadataListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProviderOperationsMetadataListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.pomlr) + if err != nil { + return err + } + page.pomlr = next + 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 *ProviderOperationsMetadataListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ProviderOperationsMetadataListResultPage) NotDone() bool { + return !page.pomlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ProviderOperationsMetadataListResultPage) Response() ProviderOperationsMetadataListResult { + return page.pomlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ProviderOperationsMetadataListResultPage) Values() []ProviderOperationsMetadata { + if page.pomlr.IsEmpty() { + return nil + } + return *page.pomlr.Value +} + +// Creates a new instance of the ProviderOperationsMetadataListResultPage type. +func NewProviderOperationsMetadataListResultPage(getNextPage func(context.Context, ProviderOperationsMetadataListResult) (ProviderOperationsMetadataListResult, error)) ProviderOperationsMetadataListResultPage { + return ProviderOperationsMetadataListResultPage{fn: getNextPage} +} + +// ResourceType resource Type +type ResourceType struct { + // Name - The resource type name. + Name *string `json:"name,omitempty"` + // DisplayName - The resource type display name. + DisplayName *string `json:"displayName,omitempty"` + // Operations - The resource type operations. + Operations *[]ProviderOperation `json:"operations,omitempty"` +} + +// RoleAssignment role Assignments +type RoleAssignment struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The role assignment ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The role assignment name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The role assignment type. + Type *string `json:"type,omitempty"` + // RoleAssignmentPropertiesWithScope - Role assignment properties. + *RoleAssignmentPropertiesWithScope `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleAssignment. +func (ra RoleAssignment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ra.RoleAssignmentPropertiesWithScope != nil { + objectMap["properties"] = ra.RoleAssignmentPropertiesWithScope + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RoleAssignment struct. +func (ra *RoleAssignment) 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 "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ra.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ra.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ra.Type = &typeVar + } + case "properties": + if v != nil { + var roleAssignmentPropertiesWithScope RoleAssignmentPropertiesWithScope + err = json.Unmarshal(*v, &roleAssignmentPropertiesWithScope) + if err != nil { + return err + } + ra.RoleAssignmentPropertiesWithScope = &roleAssignmentPropertiesWithScope + } + } + } + + return nil +} + +// RoleAssignmentCreateParameters role assignment create parameters. +type RoleAssignmentCreateParameters struct { + // RoleAssignmentProperties - Role assignment properties. + *RoleAssignmentProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleAssignmentCreateParameters. +func (racp RoleAssignmentCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if racp.RoleAssignmentProperties != nil { + objectMap["properties"] = racp.RoleAssignmentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RoleAssignmentCreateParameters struct. +func (racp *RoleAssignmentCreateParameters) 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 roleAssignmentProperties RoleAssignmentProperties + err = json.Unmarshal(*v, &roleAssignmentProperties) + if err != nil { + return err + } + racp.RoleAssignmentProperties = &roleAssignmentProperties + } + } + } + + return nil +} + +// RoleAssignmentFilter role Assignments filter +type RoleAssignmentFilter struct { + // PrincipalID - Returns role assignment of the specific principal. + PrincipalID *string `json:"principalId,omitempty"` + // CanDelegate - The Delegation flag for the role assignment + CanDelegate *bool `json:"canDelegate,omitempty"` +} + +// RoleAssignmentListResult role assignment list operation result. +type RoleAssignmentListResult struct { + autorest.Response `json:"-"` + // Value - Role assignment list. + Value *[]RoleAssignment `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// RoleAssignmentListResultIterator provides access to a complete listing of RoleAssignment values. +type RoleAssignmentListResultIterator struct { + i int + page RoleAssignmentListResultPage +} + +// 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 *RoleAssignmentListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentListResultIterator.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 *RoleAssignmentListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RoleAssignmentListResultIterator) 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 RoleAssignmentListResultIterator) Response() RoleAssignmentListResult { + 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 RoleAssignmentListResultIterator) Value() RoleAssignment { + if !iter.page.NotDone() { + return RoleAssignment{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RoleAssignmentListResultIterator type. +func NewRoleAssignmentListResultIterator(page RoleAssignmentListResultPage) RoleAssignmentListResultIterator { + return RoleAssignmentListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ralr RoleAssignmentListResult) IsEmpty() bool { + return ralr.Value == nil || len(*ralr.Value) == 0 +} + +// roleAssignmentListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ralr RoleAssignmentListResult) roleAssignmentListResultPreparer(ctx context.Context) (*http.Request, error) { + if ralr.NextLink == nil || len(to.String(ralr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ralr.NextLink))) +} + +// RoleAssignmentListResultPage contains a page of RoleAssignment values. +type RoleAssignmentListResultPage struct { + fn func(context.Context, RoleAssignmentListResult) (RoleAssignmentListResult, error) + ralr RoleAssignmentListResult +} + +// 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 *RoleAssignmentListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.ralr) + if err != nil { + return err + } + page.ralr = next + 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 *RoleAssignmentListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RoleAssignmentListResultPage) NotDone() bool { + return !page.ralr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RoleAssignmentListResultPage) Response() RoleAssignmentListResult { + return page.ralr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RoleAssignmentListResultPage) Values() []RoleAssignment { + if page.ralr.IsEmpty() { + return nil + } + return *page.ralr.Value +} + +// Creates a new instance of the RoleAssignmentListResultPage type. +func NewRoleAssignmentListResultPage(getNextPage func(context.Context, RoleAssignmentListResult) (RoleAssignmentListResult, error)) RoleAssignmentListResultPage { + return RoleAssignmentListResultPage{fn: getNextPage} +} + +// RoleAssignmentProperties role assignment properties. +type RoleAssignmentProperties struct { + // RoleDefinitionID - The role definition ID used in the role assignment. + RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` + // PrincipalID - The principal ID assigned to the role. This maps to the ID inside the Active Directory. It can point to a user, service principal, or security group. + PrincipalID *string `json:"principalId,omitempty"` + // PrincipalType - The principal type of the assigned principal ID. Possible values include: 'User', 'Group', 'ServicePrincipal', 'Unknown', 'DirectoryRoleTemplate', 'ForeignGroup', 'Application', 'MSI', 'DirectoryObjectOrGroup', 'Everyone' + PrincipalType PrincipalType `json:"principalType,omitempty"` + // CanDelegate - The delegation flag used for creating a role assignment + CanDelegate *bool `json:"canDelegate,omitempty"` +} + +// RoleAssignmentPropertiesWithScope role assignment properties with scope. +type RoleAssignmentPropertiesWithScope struct { + // Scope - The role assignment scope. + Scope *string `json:"scope,omitempty"` + // RoleDefinitionID - The role definition ID. + RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` + // PrincipalID - The principal ID. + PrincipalID *string `json:"principalId,omitempty"` + // PrincipalType - The principal type of the assigned principal ID. Possible values include: 'User', 'Group', 'ServicePrincipal', 'Unknown', 'DirectoryRoleTemplate', 'ForeignGroup', 'Application', 'MSI', 'DirectoryObjectOrGroup', 'Everyone' + PrincipalType PrincipalType `json:"principalType,omitempty"` + // CanDelegate - The Delegation flag for the role assignment + CanDelegate *bool `json:"canDelegate,omitempty"` +} + +// RoleDefinition role definition. +type RoleDefinition struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The role definition ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The role definition name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The role definition type. + Type *string `json:"type,omitempty"` + // RoleDefinitionProperties - Role definition properties. + *RoleDefinitionProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleDefinition. +func (rd RoleDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rd.RoleDefinitionProperties != nil { + objectMap["properties"] = rd.RoleDefinitionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RoleDefinition struct. +func (rd *RoleDefinition) 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 "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rd.Type = &typeVar + } + case "properties": + if v != nil { + var roleDefinitionProperties RoleDefinitionProperties + err = json.Unmarshal(*v, &roleDefinitionProperties) + if err != nil { + return err + } + rd.RoleDefinitionProperties = &roleDefinitionProperties + } + } + } + + return nil +} + +// RoleDefinitionFilter role Definitions filter +type RoleDefinitionFilter struct { + // RoleName - Returns role definition with the specific name. + RoleName *string `json:"roleName,omitempty"` + // Type - Returns role definition with the specific type. + Type *string `json:"type,omitempty"` +} + +// RoleDefinitionListResult role definition list operation result. +type RoleDefinitionListResult struct { + autorest.Response `json:"-"` + // Value - Role definition list. + Value *[]RoleDefinition `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// RoleDefinitionListResultIterator provides access to a complete listing of RoleDefinition values. +type RoleDefinitionListResultIterator struct { + i int + page RoleDefinitionListResultPage +} + +// 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 *RoleDefinitionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionListResultIterator.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 *RoleDefinitionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RoleDefinitionListResultIterator) 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 RoleDefinitionListResultIterator) Response() RoleDefinitionListResult { + 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 RoleDefinitionListResultIterator) Value() RoleDefinition { + if !iter.page.NotDone() { + return RoleDefinition{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RoleDefinitionListResultIterator type. +func NewRoleDefinitionListResultIterator(page RoleDefinitionListResultPage) RoleDefinitionListResultIterator { + return RoleDefinitionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rdlr RoleDefinitionListResult) IsEmpty() bool { + return rdlr.Value == nil || len(*rdlr.Value) == 0 +} + +// roleDefinitionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rdlr RoleDefinitionListResult) roleDefinitionListResultPreparer(ctx context.Context) (*http.Request, error) { + if rdlr.NextLink == nil || len(to.String(rdlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rdlr.NextLink))) +} + +// RoleDefinitionListResultPage contains a page of RoleDefinition values. +type RoleDefinitionListResultPage struct { + fn func(context.Context, RoleDefinitionListResult) (RoleDefinitionListResult, error) + rdlr RoleDefinitionListResult +} + +// 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 *RoleDefinitionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.rdlr) + if err != nil { + return err + } + page.rdlr = next + 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 *RoleDefinitionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RoleDefinitionListResultPage) NotDone() bool { + return !page.rdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RoleDefinitionListResultPage) Response() RoleDefinitionListResult { + return page.rdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RoleDefinitionListResultPage) Values() []RoleDefinition { + if page.rdlr.IsEmpty() { + return nil + } + return *page.rdlr.Value +} + +// Creates a new instance of the RoleDefinitionListResultPage type. +func NewRoleDefinitionListResultPage(getNextPage func(context.Context, RoleDefinitionListResult) (RoleDefinitionListResult, error)) RoleDefinitionListResultPage { + return RoleDefinitionListResultPage{fn: getNextPage} +} + +// RoleDefinitionProperties role definition properties. +type RoleDefinitionProperties struct { + // RoleName - The role name. + RoleName *string `json:"roleName,omitempty"` + // Description - The role definition description. + Description *string `json:"description,omitempty"` + // RoleType - The role type. + RoleType *string `json:"type,omitempty"` + // Permissions - Role definition permissions. + Permissions *[]Permission `json:"permissions,omitempty"` + // AssignableScopes - Role definition assignable scopes. + AssignableScopes *[]string `json:"assignableScopes,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/permissions.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/permissions.go new file mode 100644 index 000000000000..4fcabb91de6d --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/permissions.go @@ -0,0 +1,275 @@ +package authorization + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PermissionsClient is the client for the Permissions methods of the Authorization service. +type PermissionsClient struct { + BaseClient +} + +// NewPermissionsClient creates an instance of the PermissionsClient client. +func NewPermissionsClient(subscriptionID string) PermissionsClient { + return NewPermissionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPermissionsClientWithBaseURI creates an instance of the PermissionsClient client. +func NewPermissionsClientWithBaseURI(baseURI string, subscriptionID string) PermissionsClient { + return PermissionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListForResource gets all permissions the caller has for a resource. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceProviderNamespace - the namespace of the resource provider. +// parentResourcePath - the parent resource identity. +// resourceType - the resource type of the resource. +// resourceName - the name of the resource to get the permissions for. +func (client PermissionsClient) ListForResource(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result PermissionGetResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListForResource") + defer func() { + sc := -1 + if result.pgr.Response.Response != nil { + sc = result.pgr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listForResourceNextResults + req, err := client.ListForResourcePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResource", nil, "Failure preparing request") + return + } + + resp, err := client.ListForResourceSender(req) + if err != nil { + result.pgr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResource", resp, "Failure sending request") + return + } + + result.pgr, err = client.ListForResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResource", resp, "Failure responding to request") + } + + return +} + +// ListForResourcePreparer prepares the ListForResource request. +func (client PermissionsClient) ListForResourcePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName 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 = "2018-01-01-preview" + 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/permissions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListForResourceSender sends the ListForResource request. The method will close the +// http.Response Body if it receives an error. +func (client PermissionsClient) ListForResourceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListForResourceResponder handles the response to the ListForResource request. The method always +// closes the http.Response Body. +func (client PermissionsClient) ListForResourceResponder(resp *http.Response) (result PermissionGetResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listForResourceNextResults retrieves the next set of results, if any. +func (client PermissionsClient) listForResourceNextResults(ctx context.Context, lastResults PermissionGetResult) (result PermissionGetResult, err error) { + req, err := lastResults.permissionGetResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListForResourceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListForResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListForResourceComplete enumerates all values, automatically crossing page boundaries as required. +func (client PermissionsClient) ListForResourceComplete(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result PermissionGetResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListForResource") + 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.ListForResource(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) + return +} + +// ListForResourceGroup gets all permissions the caller has for a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +func (client PermissionsClient) ListForResourceGroup(ctx context.Context, resourceGroupName string) (result PermissionGetResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListForResourceGroup") + defer func() { + sc := -1 + if result.pgr.Response.Response != nil { + sc = result.pgr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listForResourceGroupNextResults + req, err := client.ListForResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListForResourceGroupSender(req) + if err != nil { + result.pgr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResourceGroup", resp, "Failure sending request") + return + } + + result.pgr, err = client.ListForResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListForResourceGroupPreparer prepares the ListForResourceGroup request. +func (client PermissionsClient) ListForResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-01-preview" + 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/permissions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListForResourceGroupSender sends the ListForResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client PermissionsClient) ListForResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListForResourceGroupResponder handles the response to the ListForResourceGroup request. The method always +// closes the http.Response Body. +func (client PermissionsClient) ListForResourceGroupResponder(resp *http.Response) (result PermissionGetResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listForResourceGroupNextResults retrieves the next set of results, if any. +func (client PermissionsClient) listForResourceGroupNextResults(ctx context.Context, lastResults PermissionGetResult) (result PermissionGetResult, err error) { + req, err := lastResults.permissionGetResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListForResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListForResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListForResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client PermissionsClient) ListForResourceGroupComplete(ctx context.Context, resourceGroupName string) (result PermissionGetResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListForResourceGroup") + 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.ListForResourceGroup(ctx, resourceGroupName) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/provideroperationsmetadata.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/provideroperationsmetadata.go new file mode 100644 index 000000000000..c1555423f6fb --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/provideroperationsmetadata.go @@ -0,0 +1,235 @@ +package authorization + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ProviderOperationsMetadataClient is the client for the ProviderOperationsMetadata methods of the Authorization +// service. +type ProviderOperationsMetadataClient struct { + BaseClient +} + +// NewProviderOperationsMetadataClient creates an instance of the ProviderOperationsMetadataClient client. +func NewProviderOperationsMetadataClient(subscriptionID string) ProviderOperationsMetadataClient { + return NewProviderOperationsMetadataClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewProviderOperationsMetadataClientWithBaseURI creates an instance of the ProviderOperationsMetadataClient client. +func NewProviderOperationsMetadataClientWithBaseURI(baseURI string, subscriptionID string) ProviderOperationsMetadataClient { + return ProviderOperationsMetadataClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets provider operations metadata for the specified resource provider. +// Parameters: +// resourceProviderNamespace - the namespace of the resource provider. +// expand - specifies whether to expand the values. +func (client ProviderOperationsMetadataClient) Get(ctx context.Context, resourceProviderNamespace string, expand string) (result ProviderOperationsMetadata, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProviderOperationsMetadataClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceProviderNamespace, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ProviderOperationsMetadataClient) GetPreparer(ctx context.Context, resourceProviderNamespace string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), + } + + const APIVersion = "2018-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } else { + queryParameters["$expand"] = autorest.Encode("query", "resourceTypes") + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ProviderOperationsMetadataClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ProviderOperationsMetadataClient) GetResponder(resp *http.Response) (result ProviderOperationsMetadata, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets provider operations metadata for all resource providers. +// Parameters: +// expand - specifies whether to expand the values. +func (client ProviderOperationsMetadataClient) List(ctx context.Context, expand string) (result ProviderOperationsMetadataListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProviderOperationsMetadataClient.List") + defer func() { + sc := -1 + if result.pomlr.Response.Response != nil { + sc = result.pomlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.pomlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "List", resp, "Failure sending request") + return + } + + result.pomlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ProviderOperationsMetadataClient) ListPreparer(ctx context.Context, expand string) (*http.Request, error) { + const APIVersion = "2018-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } else { + queryParameters["$expand"] = autorest.Encode("query", "resourceTypes") + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Authorization/providerOperations"), + 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 ProviderOperationsMetadataClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 ProviderOperationsMetadataClient) ListResponder(resp *http.Response) (result ProviderOperationsMetadataListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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 ProviderOperationsMetadataClient) listNextResults(ctx context.Context, lastResults ProviderOperationsMetadataListResult) (result ProviderOperationsMetadataListResult, err error) { + req, err := lastResults.providerOperationsMetadataListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "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, "authorization.ProviderOperationsMetadataClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ProviderOperationsMetadataClient) ListComplete(ctx context.Context, expand string) (result ProviderOperationsMetadataListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProviderOperationsMetadataClient.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, expand) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/roleassignments.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/roleassignments.go new file mode 100644 index 000000000000..1e9d78af8613 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/roleassignments.go @@ -0,0 +1,1001 @@ +package authorization + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RoleAssignmentsClient is the client for the RoleAssignments methods of the Authorization service. +type RoleAssignmentsClient struct { + BaseClient +} + +// NewRoleAssignmentsClient creates an instance of the RoleAssignmentsClient client. +func NewRoleAssignmentsClient(subscriptionID string) RoleAssignmentsClient { + return NewRoleAssignmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRoleAssignmentsClientWithBaseURI creates an instance of the RoleAssignmentsClient client. +func NewRoleAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) RoleAssignmentsClient { + return RoleAssignmentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a role assignment. +// Parameters: +// scope - the scope of the role assignment to create. The scope can be any REST resource instance. For +// example, use '/subscriptions/{subscription-id}/' for a subscription, +// '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and +// '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' +// for a resource. +// roleAssignmentName - the name of the role assignment to create. It can be any valid GUID. +// parameters - parameters for the role assignment. +func (client RoleAssignmentsClient) Create(ctx context.Context, scope string, roleAssignmentName string, parameters RoleAssignmentCreateParameters) (result RoleAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.Create") + 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.RoleAssignmentProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.RoleAssignmentProperties.RoleDefinitionID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.RoleAssignmentProperties.PrincipalID", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("authorization.RoleAssignmentsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, scope, roleAssignmentName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client RoleAssignmentsClient) CreatePreparer(ctx context.Context, scope string, roleAssignmentName string, parameters RoleAssignmentCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleAssignmentName": autorest.Encode("path", roleAssignmentName), + "scope": scope, + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentsClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client RoleAssignmentsClient) CreateResponder(resp *http.Response) (result RoleAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateByID creates a role assignment by ID. +// Parameters: +// roleID - the ID of the role assignment to create. +// parameters - parameters for the role assignment. +func (client RoleAssignmentsClient) CreateByID(ctx context.Context, roleID string, parameters RoleAssignmentCreateParameters) (result RoleAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.CreateByID") + 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.RoleAssignmentProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.RoleAssignmentProperties.RoleDefinitionID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.RoleAssignmentProperties.PrincipalID", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("authorization.RoleAssignmentsClient", "CreateByID", err.Error()) + } + + req, err := client.CreateByIDPreparer(ctx, roleID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "CreateByID", nil, "Failure preparing request") + return + } + + resp, err := client.CreateByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "CreateByID", resp, "Failure sending request") + return + } + + result, err = client.CreateByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "CreateByID", resp, "Failure responding to request") + } + + return +} + +// CreateByIDPreparer prepares the CreateByID request. +func (client RoleAssignmentsClient) CreateByIDPreparer(ctx context.Context, roleID string, parameters RoleAssignmentCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleId": roleID, + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{roleId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateByIDSender sends the CreateByID request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentsClient) CreateByIDSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CreateByIDResponder handles the response to the CreateByID request. The method always +// closes the http.Response Body. +func (client RoleAssignmentsClient) CreateByIDResponder(resp *http.Response) (result RoleAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a role assignment. +// Parameters: +// scope - the scope of the role assignment to delete. +// roleAssignmentName - the name of the role assignment to delete. +func (client RoleAssignmentsClient) Delete(ctx context.Context, scope string, roleAssignmentName string) (result RoleAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.Delete") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, scope, roleAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client RoleAssignmentsClient) DeletePreparer(ctx context.Context, scope string, roleAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleAssignmentName": autorest.Encode("path", roleAssignmentName), + "scope": scope, + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client RoleAssignmentsClient) DeleteResponder(resp *http.Response) (result RoleAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteByID deletes a role assignment. +// Parameters: +// roleID - the ID of the role assignment to delete. +func (client RoleAssignmentsClient) DeleteByID(ctx context.Context, roleID string) (result RoleAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.DeleteByID") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeleteByIDPreparer(ctx, roleID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "DeleteByID", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "DeleteByID", resp, "Failure sending request") + return + } + + result, err = client.DeleteByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "DeleteByID", resp, "Failure responding to request") + } + + return +} + +// DeleteByIDPreparer prepares the DeleteByID request. +func (client RoleAssignmentsClient) DeleteByIDPreparer(ctx context.Context, roleID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleId": roleID, + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{roleId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteByIDSender sends the DeleteByID request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentsClient) DeleteByIDSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteByIDResponder handles the response to the DeleteByID request. The method always +// closes the http.Response Body. +func (client RoleAssignmentsClient) DeleteByIDResponder(resp *http.Response) (result RoleAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get the specified role assignment. +// Parameters: +// scope - the scope of the role assignment. +// roleAssignmentName - the name of the role assignment to get. +func (client RoleAssignmentsClient) Get(ctx context.Context, scope string, roleAssignmentName string) (result RoleAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, scope, roleAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RoleAssignmentsClient) GetPreparer(ctx context.Context, scope string, roleAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleAssignmentName": autorest.Encode("path", roleAssignmentName), + "scope": scope, + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RoleAssignmentsClient) GetResponder(resp *http.Response) (result RoleAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByID gets a role assignment by ID. +// Parameters: +// roleID - the ID of the role assignment to get. +func (client RoleAssignmentsClient) GetByID(ctx context.Context, roleID string) (result RoleAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.GetByID") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByIDPreparer(ctx, roleID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "GetByID", nil, "Failure preparing request") + return + } + + resp, err := client.GetByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "GetByID", resp, "Failure sending request") + return + } + + result, err = client.GetByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "GetByID", resp, "Failure responding to request") + } + + return +} + +// GetByIDPreparer prepares the GetByID request. +func (client RoleAssignmentsClient) GetByIDPreparer(ctx context.Context, roleID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleId": roleID, + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{roleId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByIDSender sends the GetByID request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentsClient) GetByIDSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetByIDResponder handles the response to the GetByID request. The method always +// closes the http.Response Body. +func (client RoleAssignmentsClient) GetByIDResponder(resp *http.Response) (result RoleAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets all role assignments for the subscription. +// Parameters: +// filter - the filter to apply on the operation. Use $filter=atScope() to return all role assignments at or +// above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope +// for the specified principal. +func (client RoleAssignmentsClient) List(ctx context.Context, filter string) (result RoleAssignmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.List") + defer func() { + sc := -1 + if result.ralr.Response.Response != nil { + sc = result.ralr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ralr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "List", resp, "Failure sending request") + return + } + + result.ralr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client RoleAssignmentsClient) ListPreparer(ctx context.Context, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + 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/roleAssignments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RoleAssignmentsClient) ListResponder(resp *http.Response) (result RoleAssignmentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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 RoleAssignmentsClient) listNextResults(ctx context.Context, lastResults RoleAssignmentListResult) (result RoleAssignmentListResult, err error) { + req, err := lastResults.roleAssignmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "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, "authorization.RoleAssignmentsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client RoleAssignmentsClient) ListComplete(ctx context.Context, filter string) (result RoleAssignmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.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, filter) + return +} + +// ListForResource gets role assignments for a resource. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceProviderNamespace - the namespace of the resource provider. +// parentResourcePath - the parent resource identity. +// resourceType - the resource type of the resource. +// resourceName - the name of the resource to get role assignments for. +// filter - the filter to apply on the operation. Use $filter=atScope() to return all role assignments at or +// above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope +// for the specified principal. +func (client RoleAssignmentsClient) ListForResource(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (result RoleAssignmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListForResource") + defer func() { + sc := -1 + if result.ralr.Response.Response != nil { + sc = result.ralr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listForResourceNextResults + req, err := client.ListForResourcePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResource", nil, "Failure preparing request") + return + } + + resp, err := client.ListForResourceSender(req) + if err != nil { + result.ralr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResource", resp, "Failure sending request") + return + } + + result.ralr, err = client.ListForResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResource", resp, "Failure responding to request") + } + + return +} + +// ListForResourcePreparer prepares the ListForResource request. +func (client RoleAssignmentsClient) ListForResourcePreparer(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 = "2018-09-01-preview" + 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/roleAssignments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListForResourceSender sends the ListForResource request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentsClient) ListForResourceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListForResourceResponder handles the response to the ListForResource request. The method always +// closes the http.Response Body. +func (client RoleAssignmentsClient) ListForResourceResponder(resp *http.Response) (result RoleAssignmentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listForResourceNextResults retrieves the next set of results, if any. +func (client RoleAssignmentsClient) listForResourceNextResults(ctx context.Context, lastResults RoleAssignmentListResult) (result RoleAssignmentListResult, err error) { + req, err := lastResults.roleAssignmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForResourceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListForResourceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForResourceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListForResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForResourceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListForResourceComplete enumerates all values, automatically crossing page boundaries as required. +func (client RoleAssignmentsClient) ListForResourceComplete(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (result RoleAssignmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListForResource") + 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.ListForResource(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter) + return +} + +// ListForResourceGroup gets role assignments for a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +// filter - the filter to apply on the operation. Use $filter=atScope() to return all role assignments at or +// above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope +// for the specified principal. +func (client RoleAssignmentsClient) ListForResourceGroup(ctx context.Context, resourceGroupName string, filter string) (result RoleAssignmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListForResourceGroup") + defer func() { + sc := -1 + if result.ralr.Response.Response != nil { + sc = result.ralr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listForResourceGroupNextResults + req, err := client.ListForResourceGroupPreparer(ctx, resourceGroupName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListForResourceGroupSender(req) + if err != nil { + result.ralr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResourceGroup", resp, "Failure sending request") + return + } + + result.ralr, err = client.ListForResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListForResourceGroupPreparer prepares the ListForResourceGroup request. +func (client RoleAssignmentsClient) ListForResourceGroupPreparer(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 = "2018-09-01-preview" + 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/roleAssignments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListForResourceGroupSender sends the ListForResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentsClient) ListForResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListForResourceGroupResponder handles the response to the ListForResourceGroup request. The method always +// closes the http.Response Body. +func (client RoleAssignmentsClient) ListForResourceGroupResponder(resp *http.Response) (result RoleAssignmentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listForResourceGroupNextResults retrieves the next set of results, if any. +func (client RoleAssignmentsClient) listForResourceGroupNextResults(ctx context.Context, lastResults RoleAssignmentListResult) (result RoleAssignmentListResult, err error) { + req, err := lastResults.roleAssignmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListForResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListForResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListForResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client RoleAssignmentsClient) ListForResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string) (result RoleAssignmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListForResourceGroup") + 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.ListForResourceGroup(ctx, resourceGroupName, filter) + return +} + +// ListForScope gets role assignments for a scope. +// Parameters: +// scope - the scope of the role assignments. +// filter - the filter to apply on the operation. Use $filter=atScope() to return all role assignments at or +// above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope +// for the specified principal. +func (client RoleAssignmentsClient) ListForScope(ctx context.Context, scope string, filter string) (result RoleAssignmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListForScope") + defer func() { + sc := -1 + if result.ralr.Response.Response != nil { + sc = result.ralr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listForScopeNextResults + req, err := client.ListForScopePreparer(ctx, scope, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForScope", nil, "Failure preparing request") + return + } + + resp, err := client.ListForScopeSender(req) + if err != nil { + result.ralr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForScope", resp, "Failure sending request") + return + } + + result.ralr, err = client.ListForScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForScope", resp, "Failure responding to request") + } + + return +} + +// ListForScopePreparer prepares the ListForScope request. +func (client RoleAssignmentsClient) ListForScopePreparer(ctx context.Context, scope string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2018-09-01-preview" + 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/roleAssignments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListForScopeSender sends the ListForScope request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentsClient) ListForScopeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListForScopeResponder handles the response to the ListForScope request. The method always +// closes the http.Response Body. +func (client RoleAssignmentsClient) ListForScopeResponder(resp *http.Response) (result RoleAssignmentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listForScopeNextResults retrieves the next set of results, if any. +func (client RoleAssignmentsClient) listForScopeNextResults(ctx context.Context, lastResults RoleAssignmentListResult) (result RoleAssignmentListResult, err error) { + req, err := lastResults.roleAssignmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForScopeNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListForScopeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForScopeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListForScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForScopeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListForScopeComplete enumerates all values, automatically crossing page boundaries as required. +func (client RoleAssignmentsClient) ListForScopeComplete(ctx context.Context, scope string, filter string) (result RoleAssignmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListForScope") + 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.ListForScope(ctx, scope, filter) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/roledefinitions.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/roledefinitions.go new file mode 100644 index 000000000000..8156456638c3 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/roledefinitions.go @@ -0,0 +1,469 @@ +package authorization + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RoleDefinitionsClient is the client for the RoleDefinitions methods of the Authorization service. +type RoleDefinitionsClient struct { + BaseClient +} + +// NewRoleDefinitionsClient creates an instance of the RoleDefinitionsClient client. +func NewRoleDefinitionsClient(subscriptionID string) RoleDefinitionsClient { + return NewRoleDefinitionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRoleDefinitionsClientWithBaseURI creates an instance of the RoleDefinitionsClient client. +func NewRoleDefinitionsClientWithBaseURI(baseURI string, subscriptionID string) RoleDefinitionsClient { + return RoleDefinitionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a role definition. +// Parameters: +// scope - the scope of the role definition. +// roleDefinitionID - the ID of the role definition. +// roleDefinition - the values for the role definition. +func (client RoleDefinitionsClient) CreateOrUpdate(ctx context.Context, scope string, roleDefinitionID string, roleDefinition RoleDefinition) (result RoleDefinition, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, scope, roleDefinitionID, roleDefinition) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client RoleDefinitionsClient) CreateOrUpdatePreparer(ctx context.Context, scope string, roleDefinitionID string, roleDefinition RoleDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleDefinitionId": autorest.Encode("path", roleDefinitionID), + "scope": scope, + } + + const APIVersion = "2018-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + roleDefinition.ID = nil + roleDefinition.Name = nil + roleDefinition.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}", pathParameters), + autorest.WithJSON(roleDefinition), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client RoleDefinitionsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client RoleDefinitionsClient) CreateOrUpdateResponder(resp *http.Response) (result RoleDefinition, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a role definition. +// Parameters: +// scope - the scope of the role definition. +// roleDefinitionID - the ID of the role definition to delete. +func (client RoleDefinitionsClient) Delete(ctx context.Context, scope string, roleDefinitionID string) (result RoleDefinition, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.Delete") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, scope, roleDefinitionID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client RoleDefinitionsClient) DeletePreparer(ctx context.Context, scope string, roleDefinitionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleDefinitionId": autorest.Encode("path", roleDefinitionID), + "scope": scope, + } + + const APIVersion = "2018-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client RoleDefinitionsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client RoleDefinitionsClient) DeleteResponder(resp *http.Response) (result RoleDefinition, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get role definition by name (GUID). +// Parameters: +// scope - the scope of the role definition. +// roleDefinitionID - the ID of the role definition. +func (client RoleDefinitionsClient) Get(ctx context.Context, scope string, roleDefinitionID string) (result RoleDefinition, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, scope, roleDefinitionID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RoleDefinitionsClient) GetPreparer(ctx context.Context, scope string, roleDefinitionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleDefinitionId": autorest.Encode("path", roleDefinitionID), + "scope": scope, + } + + const APIVersion = "2018-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RoleDefinitionsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RoleDefinitionsClient) GetResponder(resp *http.Response) (result RoleDefinition, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByID gets a role definition by ID. +// Parameters: +// roleID - the fully qualified role definition ID. Use the format, +// /subscriptions/{guid}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for subscription +// level role definitions, or /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for tenant +// level role definitions. +func (client RoleDefinitionsClient) GetByID(ctx context.Context, roleID string) (result RoleDefinition, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.GetByID") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByIDPreparer(ctx, roleID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "GetByID", nil, "Failure preparing request") + return + } + + resp, err := client.GetByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "GetByID", resp, "Failure sending request") + return + } + + result, err = client.GetByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "GetByID", resp, "Failure responding to request") + } + + return +} + +// GetByIDPreparer prepares the GetByID request. +func (client RoleDefinitionsClient) GetByIDPreparer(ctx context.Context, roleID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleId": roleID, + } + + const APIVersion = "2018-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{roleId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByIDSender sends the GetByID request. The method will close the +// http.Response Body if it receives an error. +func (client RoleDefinitionsClient) GetByIDSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetByIDResponder handles the response to the GetByID request. The method always +// closes the http.Response Body. +func (client RoleDefinitionsClient) GetByIDResponder(resp *http.Response) (result RoleDefinition, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get all role definitions that are applicable at scope and above. +// Parameters: +// scope - the scope of the role definition. +// filter - the filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as +// well. +func (client RoleDefinitionsClient) List(ctx context.Context, scope string, filter string) (result RoleDefinitionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.List") + defer func() { + sc := -1 + if result.rdlr.Response.Response != nil { + sc = result.rdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, scope, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.rdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "List", resp, "Failure sending request") + return + } + + result.rdlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client RoleDefinitionsClient) ListPreparer(ctx context.Context, scope string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2018-01-01-preview" + 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/roleDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client RoleDefinitionsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 RoleDefinitionsClient) ListResponder(resp *http.Response) (result RoleDefinitionListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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 RoleDefinitionsClient) listNextResults(ctx context.Context, lastResults RoleDefinitionListResult) (result RoleDefinitionListResult, err error) { + req, err := lastResults.roleDefinitionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "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, "authorization.RoleDefinitionsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client RoleDefinitionsClient) ListComplete(ctx context.Context, scope string, filter string) (result RoleDefinitionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.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, scope, filter) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/version.go new file mode 100644 index 000000000000..49b7cac448c0 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization/version.go @@ -0,0 +1,30 @@ +package authorization + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " authorization/2018-09-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/vendor/modules.txt b/vendor/modules.txt index b1cb3f1f51a6..d83dd51a0a3d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -40,7 +40,7 @@ github.com/Azure/azure-sdk-for-go/services/mysql/mgmt/2017-12-01/mysql github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network github.com/Azure/azure-sdk-for-go/services/notificationhubs/mgmt/2017-04-01/notificationhubs github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2017-12-01/postgresql -github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization +github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization github.com/Azure/azure-sdk-for-go/services/preview/devspaces/mgmt/2018-06-01-preview/devspaces github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid @@ -64,7 +64,6 @@ github.com/Azure/azure-sdk-for-go/services/relay/mgmt/2017-04-01/relay github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/policy github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources -github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-06-01/subscriptions github.com/Azure/azure-sdk-for-go/services/scheduler/mgmt/2016-03-01/scheduler github.com/Azure/azure-sdk-for-go/services/search/mgmt/2015-08-19/search github.com/Azure/azure-sdk-for-go/services/servicebus/mgmt/2017-04-01/servicebus @@ -74,6 +73,8 @@ github.com/Azure/azure-sdk-for-go/services/streamanalytics/mgmt/2016-03-01/strea github.com/Azure/azure-sdk-for-go/services/trafficmanager/mgmt/2018-04-01/trafficmanager github.com/Azure/azure-sdk-for-go/services/web/mgmt/2018-02-01/web github.com/Azure/azure-sdk-for-go/storage +github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization +github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-06-01/subscriptions github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources github.com/Azure/azure-sdk-for-go/version # github.com/Azure/go-autorest/autorest v0.3.0 From 5c9f1bfa76f409738a0d9f73ebd4a6f227eb1945 Mon Sep 17 00:00:00 2001 From: Justin Smith Date: Mon, 12 Aug 2019 11:48:00 -0600 Subject: [PATCH 02/10] Fixing typo in test names --- azurerm/resource_arm_role_assignment_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/azurerm/resource_arm_role_assignment_test.go b/azurerm/resource_arm_role_assignment_test.go index 63c34fe6d46b..ca6905475b63 100644 --- a/azurerm/resource_arm_role_assignment_test.go +++ b/azurerm/resource_arm_role_assignment_test.go @@ -207,7 +207,7 @@ func testAccAzureRMActiveDirectoryServicePrincipal_servicePrincipal(t *testing.T CheckDestroy: testCheckAzureRMRoleAssignmentDestroy, Steps: []resource.TestStep{ { - Config: testAccAzureRMRoleAssingment_servicePrincipal(ri, id), + Config: testAccAzureRMRoleAssignment_servicePrincipal(ri, id), Check: resource.ComposeTestCheckFunc( testCheckAzureRMRoleAssignmentExists("azurerm_role_assignment.test"), ), @@ -226,7 +226,7 @@ func testAccAzureRMActiveDirectoryServicePrincipal_group(t *testing.T) { CheckDestroy: testCheckAzureRMRoleAssignmentDestroy, Steps: []resource.TestStep{ { - Config: testAccAzureRMRoleAssingment_group(ri, id), + Config: testAccAzureRMRoleAssignment_group(ri, id), Check: resource.ComposeTestCheckFunc( testCheckAzureRMRoleAssignmentExists("azurerm_role_assignment.test"), ), @@ -398,7 +398,7 @@ resource "azurerm_role_assignment" "test" { `, roleDefinitionId, rInt, roleAssignmentId) } -func testAccAzureRMRoleAssingment_servicePrincipal(rInt int, roleAssignmentID string) string { +func testAccAzureRMRoleAssignment_servicePrincipal(rInt int, roleAssignmentID string) string { return fmt.Sprintf(` data "azurerm_subscription" "current" {} @@ -419,7 +419,7 @@ resource "azurerm_role_assignment" "test" { `, rInt, roleAssignmentID) } -func testAccAzureRMRoleAssingment_group(rInt int, roleAssignmentID string) string { +func testAccAzureRMRoleAssignment_group(rInt int, roleAssignmentID string) string { return fmt.Sprintf(` data "azurerm_subscription" "current" {} From 713d589cccb42c40034c018f695fb349bf8cfb9b Mon Sep 17 00:00:00 2001 From: Justin Smith Date: Mon, 12 Aug 2019 11:48:58 -0600 Subject: [PATCH 03/10] Adding test for Management Groups --- azurerm/resource_arm_role_assignment_test.go | 43 ++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/azurerm/resource_arm_role_assignment_test.go b/azurerm/resource_arm_role_assignment_test.go index ca6905475b63..a5c4104705ea 100644 --- a/azurerm/resource_arm_role_assignment_test.go +++ b/azurerm/resource_arm_role_assignment_test.go @@ -287,6 +287,30 @@ func testCheckAzureRMRoleAssignmentDestroy(s *terraform.State) error { return nil } +func testAccAzureRMRoleAssignment_managementGroup(t *testing.T) { + resourceName := "azurerm_role_assignment.test" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMRoleAssignmentDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMRoleAssignment_emptyNameConfig(), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMRoleAssignmentExists(resourceName), + resource.TestCheckResourceAttrSet(resourceName, "name"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAzureRMRoleAssignment_emptyNameConfig() string { return ` data "azurerm_subscription" "primary" {} @@ -435,3 +459,22 @@ resource "azurerm_role_assignment" "test" { } `, rInt, roleAssignmentID) } + +func testAccAzureRMRoleAssignment_managementGroupConfig() string { + return ` +data "azurerm_subscription" "primary" {} + +data "azurerm_client_config" "test" {} + +data "azurerm_builtin_role_definition" "test" { + name = "Monitoring Reader" +} + +data "azurerm_management_group" "test" {} + resource "azurerm_role_assignment" "test" { + scope = "${data.azurerm_subscription.primary.id}${data.azurerm_management_group.test.id}" + role_definition_id = "${data.azurerm_subscription.primary.id}${data.azurerm_builtin_role_definition.test.id}" + principal_id = "${data.azurerm_client_config.test.service_principal_object_id}" +} +` +} From 811ff7cae1666c96dfb183f786eacce41e75453f Mon Sep 17 00:00:00 2001 From: Justin Smith Date: Mon, 12 Aug 2019 11:55:50 -0600 Subject: [PATCH 04/10] Fixing scope to only include the Management Group --- azurerm/resource_arm_role_assignment_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/resource_arm_role_assignment_test.go b/azurerm/resource_arm_role_assignment_test.go index a5c4104705ea..9effe6a82fa2 100644 --- a/azurerm/resource_arm_role_assignment_test.go +++ b/azurerm/resource_arm_role_assignment_test.go @@ -472,7 +472,7 @@ data "azurerm_builtin_role_definition" "test" { data "azurerm_management_group" "test" {} resource "azurerm_role_assignment" "test" { - scope = "${data.azurerm_subscription.primary.id}${data.azurerm_management_group.test.id}" + scope = "${data.azurerm_management_group.test.id}" role_definition_id = "${data.azurerm_subscription.primary.id}${data.azurerm_builtin_role_definition.test.id}" principal_id = "${data.azurerm_client_config.test.service_principal_object_id}" } From 304466bf94abbe8b4a22d34adb8d6bdaf183c76b Mon Sep 17 00:00:00 2001 From: Justin Smith Date: Mon, 12 Aug 2019 12:06:22 -0600 Subject: [PATCH 05/10] Formatting with make fmt --- azurerm/resource_arm_role_assignment_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/resource_arm_role_assignment_test.go b/azurerm/resource_arm_role_assignment_test.go index 9effe6a82fa2..46693f908c83 100644 --- a/azurerm/resource_arm_role_assignment_test.go +++ b/azurerm/resource_arm_role_assignment_test.go @@ -290,7 +290,7 @@ func testCheckAzureRMRoleAssignmentDestroy(s *terraform.State) error { func testAccAzureRMRoleAssignment_managementGroup(t *testing.T) { resourceName := "azurerm_role_assignment.test" - resource.Test(t, resource.TestCase{ + resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testCheckAzureRMRoleAssignmentDestroy, From f42883d70058875b6cd86b296efbafd6e9e6d5c3 Mon Sep 17 00:00:00 2001 From: Justin Smith Date: Mon, 12 Aug 2019 12:59:50 -0600 Subject: [PATCH 06/10] Updated client.go to use 2018-09-01 --- azurerm/internal/services/authorization/client.go | 2 +- go.sum | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/azurerm/internal/services/authorization/client.go b/azurerm/internal/services/authorization/client.go index 5c50b5a5205f..6a355d44426d 100644 --- a/azurerm/internal/services/authorization/client.go +++ b/azurerm/internal/services/authorization/client.go @@ -1,7 +1,7 @@ package authorization import ( - "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization" + "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common" ) diff --git a/go.sum b/go.sum index b1bba211deb6..cc2da7a71a93 100644 --- a/go.sum +++ b/go.sum @@ -20,6 +20,7 @@ github.com/Azure/azure-sdk-for-go v30.0.0+incompatible h1:6o1Yzl7wTBYg+xw0pY4qna github.com/Azure/azure-sdk-for-go v30.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/azure-sdk-for-go v31.0.0+incompatible h1:18nT+M3yxnWcO66yoJyomlCoKMu578UHh0DjJBA5c1M= github.com/Azure/azure-sdk-for-go v31.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go v32.3.0+incompatible h1:cPbYVpshHJc/lWNk0Gzhf8SLN+7qpdb8RQnRh0gntcI= github.com/Azure/go-autorest v10.15.4+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= github.com/Azure/go-autorest v11.7.0+incompatible h1:gzma19dc9ejB75D90E5S+/wXouzpZyA+CV+/MJPSD/k= github.com/Azure/go-autorest v11.7.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= From c957a516db7426d6b7fbc3d7436c1d65f655de23 Mon Sep 17 00:00:00 2001 From: Justin Smith Date: Mon, 12 Aug 2019 13:07:59 -0600 Subject: [PATCH 07/10] Adding test to list of testCases --- azurerm/resource_arm_role_assignment_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azurerm/resource_arm_role_assignment_test.go b/azurerm/resource_arm_role_assignment_test.go index 46693f908c83..1b76a8d93be3 100644 --- a/azurerm/resource_arm_role_assignment_test.go +++ b/azurerm/resource_arm_role_assignment_test.go @@ -26,6 +26,7 @@ func TestAccAzureRMRoleAssignment(t *testing.T) { "assignment": { "sp": testAccAzureRMActiveDirectoryServicePrincipal_servicePrincipal, "group": testAccAzureRMActiveDirectoryServicePrincipal_group, + "mgmt": testAccAzureRMRoleAssignment_managementGroup, }, } @@ -296,7 +297,7 @@ func testAccAzureRMRoleAssignment_managementGroup(t *testing.T) { CheckDestroy: testCheckAzureRMRoleAssignmentDestroy, Steps: []resource.TestStep{ { - Config: testAccAzureRMRoleAssignment_emptyNameConfig(), + Config: testAccAzureRMRoleAssignment_managementGroupConfig(), Check: resource.ComposeTestCheckFunc( testCheckAzureRMRoleAssignmentExists(resourceName), resource.TestCheckResourceAttrSet(resourceName, "name"), From 5e4925087a12a2a4c8ad065f1c736b7cad4778dc Mon Sep 17 00:00:00 2001 From: Justin Smith Date: Mon, 12 Aug 2019 14:33:11 -0600 Subject: [PATCH 08/10] Formatting and documentation update --- azurerm/resource_arm_role_assignment_test.go | 3 +- website/docs/r/role_assignment.html.markdown | 34 +++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/azurerm/resource_arm_role_assignment_test.go b/azurerm/resource_arm_role_assignment_test.go index 1b76a8d93be3..3ba491aa0a9c 100644 --- a/azurerm/resource_arm_role_assignment_test.go +++ b/azurerm/resource_arm_role_assignment_test.go @@ -472,7 +472,8 @@ data "azurerm_builtin_role_definition" "test" { } data "azurerm_management_group" "test" {} - resource "azurerm_role_assignment" "test" { + +resource "azurerm_role_assignment" "test" { scope = "${data.azurerm_management_group.test.id}" role_definition_id = "${data.azurerm_subscription.primary.id}${data.azurerm_builtin_role_definition.test.id}" principal_id = "${data.azurerm_client_config.test.service_principal_object_id}" diff --git a/website/docs/r/role_assignment.html.markdown b/website/docs/r/role_assignment.html.markdown index 909805d0e152..294a06f58935 100644 --- a/website/docs/r/role_assignment.html.markdown +++ b/website/docs/r/role_assignment.html.markdown @@ -85,13 +85,45 @@ resource "azurerm_role_assignment" "test" { } ``` +## Example Usage (Custom Role & Management Group) + +```hcl +data "azurerm_subscription" "primary" {} + +data "azurerm_client_config" "test" {} + +data "azurerm_management_group" "test" {} + +resource "azurerm_role_definition" "test" { + role_definition_id = "00000000-0000-0000-0000-000000000000" + name = "my-custom-role-definition" + scope = "${data.azurerm_subscription.primary.id}" + + permissions { + actions = ["Microsoft.Resources/subscriptions/resourceGroups/read"] + not_actions = [] + } + + assignable_scopes = [ + "${data.azurerm_subscription.primary.id}", + ] +} + +resource "azurerm_role_assignment" "test" { + name = "00000000-0000-0000-0000-000000000000" + scope = "${data.azurerm_management_group.primary.id}" + role_definition_id = "${azurerm_role_definition.test.id}" + principal_id = "${data.azurerm_client_config.test.client_id}" +} +``` + ## Argument Reference The following arguments are supported: * `name` - (Optional) A unique UUID/GUID for this Role Assignment - one will be generated if not specified. Changing this forces a new resource to be created. -* `scope` - (Required) The scope at which the Role Assignment applies too, such as `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333`, `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup`, or `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup/providers/Microsoft.Compute/virtualMachines/myVM`. Changing this forces a new resource to be created. +* `scope` - (Required) The scope at which the Role Assignment applies to, such as `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333`, `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup`, or `/subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup/providers/Microsoft.Compute/virtualMachines/myVM`, or `/providers/Microsoft.Management/managementGroups/myMG`. Changing this forces a new resource to be created. * `role_definition_id` - (Optional) The Scoped-ID of the Role Definition. Changing this forces a new resource to be created. Conflicts with `role_definition_name`. From 07801c60e00b60d6ba694bf5d8aa25e9c3a3794d Mon Sep 17 00:00:00 2001 From: Justin Smith Date: Mon, 12 Aug 2019 17:00:14 -0600 Subject: [PATCH 09/10] Failing with: "testing.go:568: Step 0 error: After applying this step, the plan was not empty" --- azurerm/resource_arm_role_assignment_test.go | 32 +++++++++----------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/azurerm/resource_arm_role_assignment_test.go b/azurerm/resource_arm_role_assignment_test.go index 3ba491aa0a9c..51c9fc6a507a 100644 --- a/azurerm/resource_arm_role_assignment_test.go +++ b/azurerm/resource_arm_role_assignment_test.go @@ -26,7 +26,9 @@ func TestAccAzureRMRoleAssignment(t *testing.T) { "assignment": { "sp": testAccAzureRMActiveDirectoryServicePrincipal_servicePrincipal, "group": testAccAzureRMActiveDirectoryServicePrincipal_group, - "mgmt": testAccAzureRMRoleAssignment_managementGroup, + }, + "management": { + "assign": testAccAzureRMRoleAssignment_managementGroup, }, } @@ -289,7 +291,7 @@ func testCheckAzureRMRoleAssignmentDestroy(s *terraform.State) error { } func testAccAzureRMRoleAssignment_managementGroup(t *testing.T) { - resourceName := "azurerm_role_assignment.test" + groupId := uuid.New().String() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -297,17 +299,11 @@ func testAccAzureRMRoleAssignment_managementGroup(t *testing.T) { CheckDestroy: testCheckAzureRMRoleAssignmentDestroy, Steps: []resource.TestStep{ { - Config: testAccAzureRMRoleAssignment_managementGroupConfig(), + Config: testAccAzureRMRoleAssignment_managementGroupConfig(groupId), Check: resource.ComposeTestCheckFunc( - testCheckAzureRMRoleAssignmentExists(resourceName), - resource.TestCheckResourceAttrSet(resourceName, "name"), + testCheckAzureRMRoleAssignmentExists("azurerm_role_assignment.test"), ), }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, }, }) } @@ -461,22 +457,24 @@ resource "azurerm_role_assignment" "test" { `, rInt, roleAssignmentID) } -func testAccAzureRMRoleAssignment_managementGroupConfig() string { - return ` +func testAccAzureRMRoleAssignment_managementGroupConfig(groupId string) string { + return fmt.Sprintf(` data "azurerm_subscription" "primary" {} data "azurerm_client_config" "test" {} -data "azurerm_builtin_role_definition" "test" { +data "azurerm_role_definition" "test" { name = "Monitoring Reader" } -data "azurerm_management_group" "test" {} +resource "azurerm_management_group" "test" { + group_id = "%s" +} resource "azurerm_role_assignment" "test" { - scope = "${data.azurerm_management_group.test.id}" - role_definition_id = "${data.azurerm_subscription.primary.id}${data.azurerm_builtin_role_definition.test.id}" + scope = "${azurerm_management_group.test.id}" + role_definition_id = "${data.azurerm_subscription.primary.id}${data.azurerm_role_definition.test.id}" principal_id = "${data.azurerm_client_config.test.service_principal_object_id}" } -` +`, groupId) } From 87f17bbd889fd1d84f50b1685965a4b2b0b7c77b Mon Sep 17 00:00:00 2001 From: nexxai Date: Tue, 13 Aug 2019 09:12:11 -0600 Subject: [PATCH 10/10] Fixed broken test; is passing now --- azurerm/resource_arm_role_assignment_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/resource_arm_role_assignment_test.go b/azurerm/resource_arm_role_assignment_test.go index 51c9fc6a507a..7caa13fe8ec0 100644 --- a/azurerm/resource_arm_role_assignment_test.go +++ b/azurerm/resource_arm_role_assignment_test.go @@ -473,7 +473,7 @@ resource "azurerm_management_group" "test" { resource "azurerm_role_assignment" "test" { scope = "${azurerm_management_group.test.id}" - role_definition_id = "${data.azurerm_subscription.primary.id}${data.azurerm_role_definition.test.id}" + role_definition_id = "${data.azurerm_role_definition.test.id}" principal_id = "${data.azurerm_client_config.test.service_principal_object_id}" } `, groupId)