diff --git a/services/authorization/mgmt/2015-07-01/authorization/CHANGELOG.md b/services/authorization/mgmt/2015-07-01/authorization/CHANGELOG.md index 52911e4cc5e4..c1b6629a9798 100644 --- a/services/authorization/mgmt/2015-07-01/authorization/CHANGELOG.md +++ b/services/authorization/mgmt/2015-07-01/authorization/CHANGELOG.md @@ -1,2 +1,43 @@ -# Change History +# Unreleased +## Breaking Changes + +### Signature Changes + +#### Funcs + +1. ProviderOperationsMetadataClient.Get + - Params + - From: context.Context, string, string, string + - To: context.Context, string, string +1. ProviderOperationsMetadataClient.GetPreparer + - Params + - From: context.Context, string, string, string + - To: context.Context, string, string +1. ProviderOperationsMetadataClient.List + - Params + - From: context.Context, string, string + - To: context.Context, string +1. ProviderOperationsMetadataClient.ListComplete + - Params + - From: context.Context, string, string + - To: context.Context, string +1. ProviderOperationsMetadataClient.ListPreparer + - Params + - From: context.Context, string, string + - To: context.Context, string + +## Additive Changes + +### New Funcs + +1. ErrorAdditionalInfo.MarshalJSON() ([]byte, error) +1. ErrorDetail.MarshalJSON() ([]byte, error) + +### Struct Changes + +#### New Structs + +1. ErrorAdditionalInfo +1. ErrorDetail +1. ErrorResponse diff --git a/services/authorization/mgmt/2015-07-01/authorization/_meta.json b/services/authorization/mgmt/2015-07-01/authorization/_meta.json index 245f888ed4c0..26c39454842b 100644 --- a/services/authorization/mgmt/2015-07-01/authorization/_meta.json +++ b/services/authorization/mgmt/2015-07-01/authorization/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "8bae7cfd0d36f34d22b22a8072acfd2a54861415", "readme": "/_/azure-rest-api-specs/specification/authorization/resource-manager/readme.md", "tag": "package-2015-07-01", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/authorization/mgmt/2015-07-01/authorization/authorizationapi/interfaces.go b/services/authorization/mgmt/2015-07-01/authorization/authorizationapi/interfaces.go index abe0fe9e4378..d4328f8c201e 100644 --- a/services/authorization/mgmt/2015-07-01/authorization/authorizationapi/interfaces.go +++ b/services/authorization/mgmt/2015-07-01/authorization/authorizationapi/interfaces.go @@ -36,9 +36,9 @@ var _ RoleDefinitionsClientAPI = (*authorization.RoleDefinitionsClient)(nil) // ProviderOperationsMetadataClientAPI contains the set of methods on the ProviderOperationsMetadataClient type. type ProviderOperationsMetadataClientAPI interface { - Get(ctx context.Context, resourceProviderNamespace string, APIVersion string, expand string) (result authorization.ProviderOperationsMetadata, err error) - List(ctx context.Context, APIVersion string, expand string) (result authorization.ProviderOperationsMetadataListResultPage, err error) - ListComplete(ctx context.Context, APIVersion string, expand string) (result authorization.ProviderOperationsMetadataListResultIterator, err error) + Get(ctx context.Context, resourceProviderNamespace string, expand string) (result authorization.ProviderOperationsMetadata, err error) + List(ctx context.Context, expand string) (result authorization.ProviderOperationsMetadataListResultPage, err error) + ListComplete(ctx context.Context, expand string) (result authorization.ProviderOperationsMetadataListResultIterator, err error) } var _ ProviderOperationsMetadataClientAPI = (*authorization.ProviderOperationsMetadataClient)(nil) diff --git a/services/authorization/mgmt/2015-07-01/authorization/classicadministrators.go b/services/authorization/mgmt/2015-07-01/authorization/classicadministrators.go index cdff22469469..d0e42af959e3 100644 --- a/services/authorization/mgmt/2015-07-01/authorization/classicadministrators.go +++ b/services/authorization/mgmt/2015-07-01/authorization/classicadministrators.go @@ -10,6 +10,7 @@ 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" ) @@ -46,6 +47,12 @@ func (client ClassicAdministratorsClient) List(ctx context.Context) (result Clas tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.ClassicAdministratorsClient", "List", err.Error()) + } + result.fn = client.listNextResults req, err := client.ListPreparer(ctx) if err != nil { diff --git a/services/authorization/mgmt/2015-07-01/authorization/models.go b/services/authorization/mgmt/2015-07-01/authorization/models.go index 79d95b5c8d46..668001bf0aff 100644 --- a/services/authorization/mgmt/2015-07-01/authorization/models.go +++ b/services/authorization/mgmt/2015-07-01/authorization/models.go @@ -267,6 +267,47 @@ type ClassicAdministratorProperties struct { Role *string `json:"role,omitempty"` } +// ErrorAdditionalInfo the resource management error additional info. +type ErrorAdditionalInfo struct { + // Type - READ-ONLY; The additional info type. + Type *string `json:"type,omitempty"` + // Info - READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorAdditionalInfo. +func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorDetail the error detail. +type ErrorDetail struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The error target. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; The error details. + Details *[]ErrorDetail `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDetail. +func (ed ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorResponse common error response for all Azure Resource Manager APIs to return error details for +// failed operations. (This also follows the OData error response format.). +type ErrorResponse struct { + // Error - The error object. + Error *ErrorDetail `json:"error,omitempty"` +} + // Permission role definition permissions. type Permission struct { // Actions - Allowed actions. diff --git a/services/authorization/mgmt/2015-07-01/authorization/permissions.go b/services/authorization/mgmt/2015-07-01/authorization/permissions.go index a3358cbeb722..6acd393f3a27 100644 --- a/services/authorization/mgmt/2015-07-01/authorization/permissions.go +++ b/services/authorization/mgmt/2015-07-01/authorization/permissions.go @@ -10,6 +10,7 @@ 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" ) @@ -35,7 +36,7 @@ func NewPermissionsClientWithBaseURI(baseURI string, subscriptionID string) Perm // ListForResource gets all permissions the caller has for a resource. // Parameters: -// resourceGroupName - the name of the resource group containing the resource. The name is case insensitive. +// resourceGroupName - the name of the resource group. The name is case insensitive. // resourceProviderNamespace - the namespace of the resource provider. // parentResourcePath - the parent resource identity. // resourceType - the resource type of the resource. @@ -51,6 +52,15 @@ func (client PermissionsClient) ListForResource(ctx context.Context, resourceGro tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.PermissionsClient", "ListForResource", err.Error()) + } + result.fn = client.listForResourceNextResults req, err := client.ListForResourcePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) if err != nil { @@ -159,7 +169,7 @@ func (client PermissionsClient) ListForResourceComplete(ctx context.Context, res // ListForResourceGroup gets all permissions the caller has for a resource group. // Parameters: -// resourceGroupName - the name of the resource group to get the permissions for. The name is case insensitive. +// resourceGroupName - the name of the resource group. The name is case insensitive. func (client PermissionsClient) ListForResourceGroup(ctx context.Context, resourceGroupName string) (result PermissionGetResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListForResourceGroup") @@ -171,6 +181,15 @@ func (client PermissionsClient) ListForResourceGroup(ctx context.Context, resour tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.PermissionsClient", "ListForResourceGroup", err.Error()) + } + result.fn = client.listForResourceGroupNextResults req, err := client.ListForResourceGroupPreparer(ctx, resourceGroupName) if err != nil { diff --git a/services/authorization/mgmt/2015-07-01/authorization/provideroperationsmetadata.go b/services/authorization/mgmt/2015-07-01/authorization/provideroperationsmetadata.go index ac10ce7754d9..01c464a610e8 100644 --- a/services/authorization/mgmt/2015-07-01/authorization/provideroperationsmetadata.go +++ b/services/authorization/mgmt/2015-07-01/authorization/provideroperationsmetadata.go @@ -37,9 +37,8 @@ func NewProviderOperationsMetadataClientWithBaseURI(baseURI string, subscription // Get gets provider operations metadata for the specified resource provider. // Parameters: // resourceProviderNamespace - the namespace of the resource provider. -// APIVersion - the API version to use for the operation. // expand - specifies whether to expand the values. -func (client ProviderOperationsMetadataClient) Get(ctx context.Context, resourceProviderNamespace string, APIVersion string, expand string) (result ProviderOperationsMetadata, err error) { +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() { @@ -50,7 +49,7 @@ func (client ProviderOperationsMetadataClient) Get(ctx context.Context, resource tracing.EndSpan(ctx, sc, err) }() } - req, err := client.GetPreparer(ctx, resourceProviderNamespace, APIVersion, expand) + req, err := client.GetPreparer(ctx, resourceProviderNamespace, expand) if err != nil { err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "Get", nil, "Failure preparing request") return @@ -73,11 +72,12 @@ func (client ProviderOperationsMetadataClient) Get(ctx context.Context, resource } // GetPreparer prepares the Get request. -func (client ProviderOperationsMetadataClient) GetPreparer(ctx context.Context, resourceProviderNamespace string, APIVersion string, expand string) (*http.Request, error) { +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 = "2015-07-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -115,9 +115,8 @@ func (client ProviderOperationsMetadataClient) GetResponder(resp *http.Response) // List gets provider operations metadata for all resource providers. // Parameters: -// APIVersion - the API version to use for this operation. // expand - specifies whether to expand the values. -func (client ProviderOperationsMetadataClient) List(ctx context.Context, APIVersion string, expand string) (result ProviderOperationsMetadataListResultPage, err error) { +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() { @@ -129,7 +128,7 @@ func (client ProviderOperationsMetadataClient) List(ctx context.Context, APIVers }() } result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, APIVersion, expand) + req, err := client.ListPreparer(ctx, expand) if err != nil { err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "List", nil, "Failure preparing request") return @@ -156,7 +155,8 @@ func (client ProviderOperationsMetadataClient) List(ctx context.Context, APIVers } // ListPreparer prepares the List request. -func (client ProviderOperationsMetadataClient) ListPreparer(ctx context.Context, APIVersion string, expand string) (*http.Request, error) { +func (client ProviderOperationsMetadataClient) ListPreparer(ctx context.Context, expand string) (*http.Request, error) { + const APIVersion = "2015-07-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -214,7 +214,7 @@ func (client ProviderOperationsMetadataClient) listNextResults(ctx context.Conte } // ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client ProviderOperationsMetadataClient) ListComplete(ctx context.Context, APIVersion string, expand string) (result ProviderOperationsMetadataListResultIterator, err error) { +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() { @@ -225,6 +225,6 @@ func (client ProviderOperationsMetadataClient) ListComplete(ctx context.Context, tracing.EndSpan(ctx, sc, err) }() } - result.page, err = client.List(ctx, APIVersion, expand) + result.page, err = client.List(ctx, expand) return } diff --git a/services/authorization/mgmt/2015-07-01/authorization/roleassignments.go b/services/authorization/mgmt/2015-07-01/authorization/roleassignments.go index 43897ed795c4..ddb1ee9036ce 100644 --- a/services/authorization/mgmt/2015-07-01/authorization/roleassignments.go +++ b/services/authorization/mgmt/2015-07-01/authorization/roleassignments.go @@ -41,7 +41,8 @@ func NewRoleAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) // '/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. +// roleAssignmentName - a GUID for the role assignment to create. The name must be unique and different for +// each role assignment. // 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() { @@ -281,7 +282,7 @@ func (client RoleAssignmentsClient) DeleteSender(req *http.Request) (*http.Respo func (client RoleAssignmentsClient) DeleteResponder(resp *http.Response) (result RoleAssignment, err error) { err = autorest.Respond( resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} @@ -357,7 +358,7 @@ func (client RoleAssignmentsClient) DeleteByIDSender(req *http.Request) (*http.R func (client RoleAssignmentsClient) DeleteByIDResponder(resp *http.Response) (result RoleAssignment, err error) { err = autorest.Respond( resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} @@ -531,6 +532,12 @@ func (client RoleAssignmentsClient) List(ctx context.Context, filter string) (re tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.RoleAssignmentsClient", "List", err.Error()) + } + result.fn = client.listNextResults req, err := client.ListPreparer(ctx, filter) if err != nil { @@ -637,7 +644,7 @@ func (client RoleAssignmentsClient) ListComplete(ctx context.Context, filter str // ListForResource gets role assignments for a resource. // Parameters: -// resourceGroupName - the name of the resource group. +// resourceGroupName - the name of the resource group. The name is case insensitive. // resourceProviderNamespace - the namespace of the resource provider. // parentResourcePath - the parent resource identity. // resourceType - the resource type of the resource. @@ -656,6 +663,15 @@ func (client RoleAssignmentsClient) ListForResource(ctx context.Context, resourc tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.RoleAssignmentsClient", "ListForResource", err.Error()) + } + result.fn = client.listForResourceNextResults req, err := client.ListForResourcePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter) if err != nil { @@ -767,7 +783,7 @@ func (client RoleAssignmentsClient) ListForResourceComplete(ctx context.Context, // ListForResourceGroup gets role assignments for a resource group. // Parameters: -// resourceGroupName - the name of the resource group. +// resourceGroupName - the name of the resource group. The name is case insensitive. // 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. @@ -782,6 +798,15 @@ func (client RoleAssignmentsClient) ListForResourceGroup(ctx context.Context, re tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.RoleAssignmentsClient", "ListForResourceGroup", err.Error()) + } + result.fn = client.listForResourceGroupNextResults req, err := client.ListForResourceGroupPreparer(ctx, resourceGroupName, filter) if err != nil { diff --git a/services/authorization/mgmt/2015-07-01/authorization/roledefinitions.go b/services/authorization/mgmt/2015-07-01/authorization/roledefinitions.go index 5bc63943465a..1d17715bff18 100644 --- a/services/authorization/mgmt/2015-07-01/authorization/roledefinitions.go +++ b/services/authorization/mgmt/2015-07-01/authorization/roledefinitions.go @@ -182,7 +182,7 @@ func (client RoleDefinitionsClient) DeleteSender(req *http.Request) (*http.Respo func (client RoleDefinitionsClient) DeleteResponder(resp *http.Response) (result RoleDefinition, err error) { err = autorest.Respond( resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} diff --git a/services/authorization/mgmt/2020-10-01/authorization/CHANGELOG.md b/services/authorization/mgmt/2020-10-01/authorization/CHANGELOG.md index 52911e4cc5e4..a1ecf841edb0 100644 --- a/services/authorization/mgmt/2020-10-01/authorization/CHANGELOG.md +++ b/services/authorization/mgmt/2020-10-01/authorization/CHANGELOG.md @@ -1,2 +1,2 @@ -# Change History +# Unreleased diff --git a/services/authorization/mgmt/2020-10-01/authorization/_meta.json b/services/authorization/mgmt/2020-10-01/authorization/_meta.json index c98e572dc5e2..506627e10e9f 100644 --- a/services/authorization/mgmt/2020-10-01/authorization/_meta.json +++ b/services/authorization/mgmt/2020-10-01/authorization/_meta.json @@ -1,5 +1,5 @@ { - "commit": "e7d2d8c48cf6f8f63de7e252c467930449b5fd88", + "commit": "8bae7cfd0d36f34d22b22a8072acfd2a54861415", "readme": "/_/azure-rest-api-specs/specification/authorization/resource-manager/readme.md", "tag": "package-2020-10-01", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/preview/authorization/mgmt/2017-10-01-preview/authorization/CHANGELOG.md b/services/preview/authorization/mgmt/2017-10-01-preview/authorization/CHANGELOG.md index 52911e4cc5e4..c1b6629a9798 100644 --- a/services/preview/authorization/mgmt/2017-10-01-preview/authorization/CHANGELOG.md +++ b/services/preview/authorization/mgmt/2017-10-01-preview/authorization/CHANGELOG.md @@ -1,2 +1,43 @@ -# Change History +# Unreleased +## Breaking Changes + +### Signature Changes + +#### Funcs + +1. ProviderOperationsMetadataClient.Get + - Params + - From: context.Context, string, string, string + - To: context.Context, string, string +1. ProviderOperationsMetadataClient.GetPreparer + - Params + - From: context.Context, string, string, string + - To: context.Context, string, string +1. ProviderOperationsMetadataClient.List + - Params + - From: context.Context, string, string + - To: context.Context, string +1. ProviderOperationsMetadataClient.ListComplete + - Params + - From: context.Context, string, string + - To: context.Context, string +1. ProviderOperationsMetadataClient.ListPreparer + - Params + - From: context.Context, string, string + - To: context.Context, string + +## Additive Changes + +### New Funcs + +1. ErrorAdditionalInfo.MarshalJSON() ([]byte, error) +1. ErrorDetail.MarshalJSON() ([]byte, error) + +### Struct Changes + +#### New Structs + +1. ErrorAdditionalInfo +1. ErrorDetail +1. ErrorResponse diff --git a/services/preview/authorization/mgmt/2017-10-01-preview/authorization/_meta.json b/services/preview/authorization/mgmt/2017-10-01-preview/authorization/_meta.json index 217d0a50b069..ee7aa54a2e04 100644 --- a/services/preview/authorization/mgmt/2017-10-01-preview/authorization/_meta.json +++ b/services/preview/authorization/mgmt/2017-10-01-preview/authorization/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "8bae7cfd0d36f34d22b22a8072acfd2a54861415", "readme": "/_/azure-rest-api-specs/specification/authorization/resource-manager/readme.md", "tag": "package-2017-10-01-preview", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/preview/authorization/mgmt/2017-10-01-preview/authorization/authorizationapi/interfaces.go b/services/preview/authorization/mgmt/2017-10-01-preview/authorization/authorizationapi/interfaces.go index 688e939cba46..fc870b5ebf99 100644 --- a/services/preview/authorization/mgmt/2017-10-01-preview/authorization/authorizationapi/interfaces.go +++ b/services/preview/authorization/mgmt/2017-10-01-preview/authorization/authorizationapi/interfaces.go @@ -44,9 +44,9 @@ var _ RoleDefinitionsClientAPI = (*authorization.RoleDefinitionsClient)(nil) // ProviderOperationsMetadataClientAPI contains the set of methods on the ProviderOperationsMetadataClient type. type ProviderOperationsMetadataClientAPI interface { - Get(ctx context.Context, resourceProviderNamespace string, APIVersion string, expand string) (result authorization.ProviderOperationsMetadata, err error) - List(ctx context.Context, APIVersion string, expand string) (result authorization.ProviderOperationsMetadataListResultPage, err error) - ListComplete(ctx context.Context, APIVersion string, expand string) (result authorization.ProviderOperationsMetadataListResultIterator, err error) + Get(ctx context.Context, resourceProviderNamespace string, expand string) (result authorization.ProviderOperationsMetadata, err error) + List(ctx context.Context, expand string) (result authorization.ProviderOperationsMetadataListResultPage, err error) + ListComplete(ctx context.Context, expand string) (result authorization.ProviderOperationsMetadataListResultIterator, err error) } var _ ProviderOperationsMetadataClientAPI = (*authorization.ProviderOperationsMetadataClient)(nil) diff --git a/services/preview/authorization/mgmt/2017-10-01-preview/authorization/classicadministrators.go b/services/preview/authorization/mgmt/2017-10-01-preview/authorization/classicadministrators.go index 655ee7dd6eb9..273a02d510c1 100644 --- a/services/preview/authorization/mgmt/2017-10-01-preview/authorization/classicadministrators.go +++ b/services/preview/authorization/mgmt/2017-10-01-preview/authorization/classicadministrators.go @@ -10,6 +10,7 @@ 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" ) @@ -46,6 +47,12 @@ func (client ClassicAdministratorsClient) List(ctx context.Context) (result Clas tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.ClassicAdministratorsClient", "List", err.Error()) + } + result.fn = client.listNextResults req, err := client.ListPreparer(ctx) if err != nil { diff --git a/services/preview/authorization/mgmt/2017-10-01-preview/authorization/models.go b/services/preview/authorization/mgmt/2017-10-01-preview/authorization/models.go index fdabfbad4a38..c024575c2900 100644 --- a/services/preview/authorization/mgmt/2017-10-01-preview/authorization/models.go +++ b/services/preview/authorization/mgmt/2017-10-01-preview/authorization/models.go @@ -267,6 +267,47 @@ type ClassicAdministratorProperties struct { Role *string `json:"role,omitempty"` } +// ErrorAdditionalInfo the resource management error additional info. +type ErrorAdditionalInfo struct { + // Type - READ-ONLY; The additional info type. + Type *string `json:"type,omitempty"` + // Info - READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorAdditionalInfo. +func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorDetail the error detail. +type ErrorDetail struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The error target. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; The error details. + Details *[]ErrorDetail `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDetail. +func (ed ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorResponse common error response for all Azure Resource Manager APIs to return error details for +// failed operations. (This also follows the OData error response format.). +type ErrorResponse struct { + // Error - The error object. + Error *ErrorDetail `json:"error,omitempty"` +} + // Permission role definition permissions. type Permission struct { // Actions - Allowed actions. diff --git a/services/preview/authorization/mgmt/2017-10-01-preview/authorization/permissions.go b/services/preview/authorization/mgmt/2017-10-01-preview/authorization/permissions.go index a3358cbeb722..6acd393f3a27 100644 --- a/services/preview/authorization/mgmt/2017-10-01-preview/authorization/permissions.go +++ b/services/preview/authorization/mgmt/2017-10-01-preview/authorization/permissions.go @@ -10,6 +10,7 @@ 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" ) @@ -35,7 +36,7 @@ func NewPermissionsClientWithBaseURI(baseURI string, subscriptionID string) Perm // ListForResource gets all permissions the caller has for a resource. // Parameters: -// resourceGroupName - the name of the resource group containing the resource. The name is case insensitive. +// resourceGroupName - the name of the resource group. The name is case insensitive. // resourceProviderNamespace - the namespace of the resource provider. // parentResourcePath - the parent resource identity. // resourceType - the resource type of the resource. @@ -51,6 +52,15 @@ func (client PermissionsClient) ListForResource(ctx context.Context, resourceGro tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.PermissionsClient", "ListForResource", err.Error()) + } + result.fn = client.listForResourceNextResults req, err := client.ListForResourcePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) if err != nil { @@ -159,7 +169,7 @@ func (client PermissionsClient) ListForResourceComplete(ctx context.Context, res // ListForResourceGroup gets all permissions the caller has for a resource group. // Parameters: -// resourceGroupName - the name of the resource group to get the permissions for. The name is case insensitive. +// resourceGroupName - the name of the resource group. The name is case insensitive. func (client PermissionsClient) ListForResourceGroup(ctx context.Context, resourceGroupName string) (result PermissionGetResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListForResourceGroup") @@ -171,6 +181,15 @@ func (client PermissionsClient) ListForResourceGroup(ctx context.Context, resour tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.PermissionsClient", "ListForResourceGroup", err.Error()) + } + result.fn = client.listForResourceGroupNextResults req, err := client.ListForResourceGroupPreparer(ctx, resourceGroupName) if err != nil { diff --git a/services/preview/authorization/mgmt/2017-10-01-preview/authorization/provideroperationsmetadata.go b/services/preview/authorization/mgmt/2017-10-01-preview/authorization/provideroperationsmetadata.go index ac10ce7754d9..01c464a610e8 100644 --- a/services/preview/authorization/mgmt/2017-10-01-preview/authorization/provideroperationsmetadata.go +++ b/services/preview/authorization/mgmt/2017-10-01-preview/authorization/provideroperationsmetadata.go @@ -37,9 +37,8 @@ func NewProviderOperationsMetadataClientWithBaseURI(baseURI string, subscription // Get gets provider operations metadata for the specified resource provider. // Parameters: // resourceProviderNamespace - the namespace of the resource provider. -// APIVersion - the API version to use for the operation. // expand - specifies whether to expand the values. -func (client ProviderOperationsMetadataClient) Get(ctx context.Context, resourceProviderNamespace string, APIVersion string, expand string) (result ProviderOperationsMetadata, err error) { +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() { @@ -50,7 +49,7 @@ func (client ProviderOperationsMetadataClient) Get(ctx context.Context, resource tracing.EndSpan(ctx, sc, err) }() } - req, err := client.GetPreparer(ctx, resourceProviderNamespace, APIVersion, expand) + req, err := client.GetPreparer(ctx, resourceProviderNamespace, expand) if err != nil { err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "Get", nil, "Failure preparing request") return @@ -73,11 +72,12 @@ func (client ProviderOperationsMetadataClient) Get(ctx context.Context, resource } // GetPreparer prepares the Get request. -func (client ProviderOperationsMetadataClient) GetPreparer(ctx context.Context, resourceProviderNamespace string, APIVersion string, expand string) (*http.Request, error) { +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 = "2015-07-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -115,9 +115,8 @@ func (client ProviderOperationsMetadataClient) GetResponder(resp *http.Response) // List gets provider operations metadata for all resource providers. // Parameters: -// APIVersion - the API version to use for this operation. // expand - specifies whether to expand the values. -func (client ProviderOperationsMetadataClient) List(ctx context.Context, APIVersion string, expand string) (result ProviderOperationsMetadataListResultPage, err error) { +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() { @@ -129,7 +128,7 @@ func (client ProviderOperationsMetadataClient) List(ctx context.Context, APIVers }() } result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, APIVersion, expand) + req, err := client.ListPreparer(ctx, expand) if err != nil { err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "List", nil, "Failure preparing request") return @@ -156,7 +155,8 @@ func (client ProviderOperationsMetadataClient) List(ctx context.Context, APIVers } // ListPreparer prepares the List request. -func (client ProviderOperationsMetadataClient) ListPreparer(ctx context.Context, APIVersion string, expand string) (*http.Request, error) { +func (client ProviderOperationsMetadataClient) ListPreparer(ctx context.Context, expand string) (*http.Request, error) { + const APIVersion = "2015-07-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -214,7 +214,7 @@ func (client ProviderOperationsMetadataClient) listNextResults(ctx context.Conte } // ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client ProviderOperationsMetadataClient) ListComplete(ctx context.Context, APIVersion string, expand string) (result ProviderOperationsMetadataListResultIterator, err error) { +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() { @@ -225,6 +225,6 @@ func (client ProviderOperationsMetadataClient) ListComplete(ctx context.Context, tracing.EndSpan(ctx, sc, err) }() } - result.page, err = client.List(ctx, APIVersion, expand) + result.page, err = client.List(ctx, expand) return } diff --git a/services/preview/authorization/mgmt/2017-10-01-preview/authorization/roleassignments.go b/services/preview/authorization/mgmt/2017-10-01-preview/authorization/roleassignments.go index 588272836e55..2ee2aa1d7083 100644 --- a/services/preview/authorization/mgmt/2017-10-01-preview/authorization/roleassignments.go +++ b/services/preview/authorization/mgmt/2017-10-01-preview/authorization/roleassignments.go @@ -10,6 +10,7 @@ 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" ) @@ -40,7 +41,8 @@ func NewRoleAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) // '/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. +// roleAssignmentName - a GUID for the role assignment to create. The name must be unique and different for +// each role assignment. // 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() { @@ -259,7 +261,7 @@ func (client RoleAssignmentsClient) DeleteSender(req *http.Request) (*http.Respo func (client RoleAssignmentsClient) DeleteResponder(resp *http.Response) (result RoleAssignment, err error) { err = autorest.Respond( resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} @@ -332,7 +334,7 @@ func (client RoleAssignmentsClient) DeleteByIDSender(req *http.Request) (*http.R func (client RoleAssignmentsClient) DeleteByIDResponder(resp *http.Response) (result RoleAssignment, err error) { err = autorest.Respond( resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} @@ -503,6 +505,12 @@ func (client RoleAssignmentsClient) List(ctx context.Context, filter string) (re tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.RoleAssignmentsClient", "List", err.Error()) + } + result.fn = client.listNextResults req, err := client.ListPreparer(ctx, filter) if err != nil { @@ -609,7 +617,7 @@ func (client RoleAssignmentsClient) ListComplete(ctx context.Context, filter str // ListForResource gets role assignments for a resource. // Parameters: -// resourceGroupName - the name of the resource group. +// resourceGroupName - the name of the resource group. The name is case insensitive. // resourceProviderNamespace - the namespace of the resource provider. // parentResourcePath - the parent resource identity. // resourceType - the resource type of the resource. @@ -628,6 +636,15 @@ func (client RoleAssignmentsClient) ListForResource(ctx context.Context, resourc tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.RoleAssignmentsClient", "ListForResource", err.Error()) + } + result.fn = client.listForResourceNextResults req, err := client.ListForResourcePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter) if err != nil { @@ -739,7 +756,7 @@ func (client RoleAssignmentsClient) ListForResourceComplete(ctx context.Context, // ListForResourceGroup gets role assignments for a resource group. // Parameters: -// resourceGroupName - the name of the resource group. +// resourceGroupName - the name of the resource group. The name is case insensitive. // 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. @@ -754,6 +771,15 @@ func (client RoleAssignmentsClient) ListForResourceGroup(ctx context.Context, re tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.RoleAssignmentsClient", "ListForResourceGroup", err.Error()) + } + result.fn = client.listForResourceGroupNextResults req, err := client.ListForResourceGroupPreparer(ctx, resourceGroupName, filter) if err != nil { diff --git a/services/preview/authorization/mgmt/2017-10-01-preview/authorization/roledefinitions.go b/services/preview/authorization/mgmt/2017-10-01-preview/authorization/roledefinitions.go index 5bc63943465a..1d17715bff18 100644 --- a/services/preview/authorization/mgmt/2017-10-01-preview/authorization/roledefinitions.go +++ b/services/preview/authorization/mgmt/2017-10-01-preview/authorization/roledefinitions.go @@ -182,7 +182,7 @@ func (client RoleDefinitionsClient) DeleteSender(req *http.Request) (*http.Respo func (client RoleDefinitionsClient) DeleteResponder(resp *http.Response) (result RoleDefinition, err error) { err = autorest.Respond( resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} diff --git a/services/preview/authorization/mgmt/2018-01-01-preview/authorization/CHANGELOG.md b/services/preview/authorization/mgmt/2018-01-01-preview/authorization/CHANGELOG.md index 52911e4cc5e4..60675616e95a 100644 --- a/services/preview/authorization/mgmt/2018-01-01-preview/authorization/CHANGELOG.md +++ b/services/preview/authorization/mgmt/2018-01-01-preview/authorization/CHANGELOG.md @@ -1,2 +1,16 @@ -# Change History +# Unreleased +## Additive Changes + +### New Funcs + +1. ErrorAdditionalInfo.MarshalJSON() ([]byte, error) +1. ErrorDetail.MarshalJSON() ([]byte, error) + +### Struct Changes + +#### New Structs + +1. ErrorAdditionalInfo +1. ErrorDetail +1. ErrorResponse diff --git a/services/preview/authorization/mgmt/2018-01-01-preview/authorization/_meta.json b/services/preview/authorization/mgmt/2018-01-01-preview/authorization/_meta.json index 4aa82e054a8c..79d465e2d164 100644 --- a/services/preview/authorization/mgmt/2018-01-01-preview/authorization/_meta.json +++ b/services/preview/authorization/mgmt/2018-01-01-preview/authorization/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "8bae7cfd0d36f34d22b22a8072acfd2a54861415", "readme": "/_/azure-rest-api-specs/specification/authorization/resource-manager/readme.md", "tag": "package-2018-01-01-preview", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/preview/authorization/mgmt/2018-01-01-preview/authorization/classicadministrators.go b/services/preview/authorization/mgmt/2018-01-01-preview/authorization/classicadministrators.go index 71dc9f3cdf7e..adb9c2979f8e 100644 --- a/services/preview/authorization/mgmt/2018-01-01-preview/authorization/classicadministrators.go +++ b/services/preview/authorization/mgmt/2018-01-01-preview/authorization/classicadministrators.go @@ -10,6 +10,7 @@ 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" ) @@ -43,6 +44,12 @@ func (client ClassicAdministratorsClient) List(ctx context.Context) (result Clas tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.ClassicAdministratorsClient", "List", err.Error()) + } + result.fn = client.listNextResults req, err := client.ListPreparer(ctx) if err != nil { diff --git a/services/preview/authorization/mgmt/2018-01-01-preview/authorization/models.go b/services/preview/authorization/mgmt/2018-01-01-preview/authorization/models.go index 1e1da38902d9..b5ddf57e6d46 100644 --- a/services/preview/authorization/mgmt/2018-01-01-preview/authorization/models.go +++ b/services/preview/authorization/mgmt/2018-01-01-preview/authorization/models.go @@ -267,6 +267,47 @@ type ClassicAdministratorProperties struct { Role *string `json:"role,omitempty"` } +// ErrorAdditionalInfo the resource management error additional info. +type ErrorAdditionalInfo struct { + // Type - READ-ONLY; The additional info type. + Type *string `json:"type,omitempty"` + // Info - READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorAdditionalInfo. +func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorDetail the error detail. +type ErrorDetail struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The error target. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; The error details. + Details *[]ErrorDetail `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDetail. +func (ed ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorResponse common error response for all Azure Resource Manager APIs to return error details for +// failed operations. (This also follows the OData error response format.). +type ErrorResponse struct { + // Error - The error object. + Error *ErrorDetail `json:"error,omitempty"` +} + // Permission role definition permissions. type Permission struct { // Actions - Allowed actions. diff --git a/services/preview/authorization/mgmt/2018-01-01-preview/authorization/permissions.go b/services/preview/authorization/mgmt/2018-01-01-preview/authorization/permissions.go index 62d87b8d120b..307f7a567df8 100644 --- a/services/preview/authorization/mgmt/2018-01-01-preview/authorization/permissions.go +++ b/services/preview/authorization/mgmt/2018-01-01-preview/authorization/permissions.go @@ -10,6 +10,7 @@ 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" ) @@ -32,7 +33,7 @@ func NewPermissionsClientWithBaseURI(baseURI string, subscriptionID string) Perm // ListForResource gets all permissions the caller has for a resource. // Parameters: -// resourceGroupName - the name of the resource group. +// resourceGroupName - the name of the resource group. The name is case insensitive. // resourceProviderNamespace - the namespace of the resource provider. // parentResourcePath - the parent resource identity. // resourceType - the resource type of the resource. @@ -48,6 +49,15 @@ func (client PermissionsClient) ListForResource(ctx context.Context, resourceGro tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.PermissionsClient", "ListForResource", err.Error()) + } + result.fn = client.listForResourceNextResults req, err := client.ListForResourcePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) if err != nil { @@ -81,7 +91,7 @@ func (client PermissionsClient) ListForResourcePreparer(ctx context.Context, res "parentResourcePath": parentResourcePath, "resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), + "resourceProviderNamespace": resourceProviderNamespace, "resourceType": resourceType, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } @@ -156,7 +166,7 @@ func (client PermissionsClient) ListForResourceComplete(ctx context.Context, res // ListForResourceGroup gets all permissions the caller has for a resource group. // Parameters: -// resourceGroupName - the name of the resource group. +// resourceGroupName - the name of the resource group. The name is case insensitive. func (client PermissionsClient) ListForResourceGroup(ctx context.Context, resourceGroupName string) (result PermissionGetResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListForResourceGroup") @@ -168,6 +178,15 @@ func (client PermissionsClient) ListForResourceGroup(ctx context.Context, resour tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.PermissionsClient", "ListForResourceGroup", err.Error()) + } + result.fn = client.listForResourceGroupNextResults req, err := client.ListForResourceGroupPreparer(ctx, resourceGroupName) if err != nil { diff --git a/services/preview/authorization/mgmt/2018-01-01-preview/authorization/provideroperationsmetadata.go b/services/preview/authorization/mgmt/2018-01-01-preview/authorization/provideroperationsmetadata.go index 359c843c0826..77cb8b9768e9 100644 --- a/services/preview/authorization/mgmt/2018-01-01-preview/authorization/provideroperationsmetadata.go +++ b/services/preview/authorization/mgmt/2018-01-01-preview/authorization/provideroperationsmetadata.go @@ -72,7 +72,7 @@ func (client ProviderOperationsMetadataClient) Get(ctx context.Context, resource // 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), + "resourceProviderNamespace": resourceProviderNamespace, } const APIVersion = "2018-01-01-preview" diff --git a/services/preview/authorization/mgmt/2018-01-01-preview/authorization/roleassignments.go b/services/preview/authorization/mgmt/2018-01-01-preview/authorization/roleassignments.go index bcfa975c050e..7b336b5c0750 100644 --- a/services/preview/authorization/mgmt/2018-01-01-preview/authorization/roleassignments.go +++ b/services/preview/authorization/mgmt/2018-01-01-preview/authorization/roleassignments.go @@ -38,7 +38,8 @@ func NewRoleAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) // '/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. +// roleAssignmentName - a GUID for the role assignment to create. The name must be unique and different for +// each role assignment. // 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() { @@ -275,7 +276,7 @@ func (client RoleAssignmentsClient) DeleteSender(req *http.Request) (*http.Respo func (client RoleAssignmentsClient) DeleteResponder(resp *http.Response) (result RoleAssignment, err error) { err = autorest.Respond( resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} @@ -348,7 +349,7 @@ func (client RoleAssignmentsClient) DeleteByIDSender(req *http.Request) (*http.R func (client RoleAssignmentsClient) DeleteByIDResponder(resp *http.Response) (result RoleAssignment, err error) { err = autorest.Respond( resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} @@ -519,6 +520,12 @@ func (client RoleAssignmentsClient) List(ctx context.Context, filter string) (re tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.RoleAssignmentsClient", "List", err.Error()) + } + result.fn = client.listNextResults req, err := client.ListPreparer(ctx, filter) if err != nil { @@ -625,7 +632,7 @@ func (client RoleAssignmentsClient) ListComplete(ctx context.Context, filter str // ListForResource gets role assignments for a resource. // Parameters: -// resourceGroupName - the name of the resource group. +// resourceGroupName - the name of the resource group. The name is case insensitive. // resourceProviderNamespace - the namespace of the resource provider. // parentResourcePath - the parent resource identity. // resourceType - the resource type of the resource. @@ -644,6 +651,15 @@ func (client RoleAssignmentsClient) ListForResource(ctx context.Context, resourc tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.RoleAssignmentsClient", "ListForResource", err.Error()) + } + result.fn = client.listForResourceNextResults req, err := client.ListForResourcePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter) if err != nil { @@ -677,7 +693,7 @@ func (client RoleAssignmentsClient) ListForResourcePreparer(ctx context.Context, "parentResourcePath": parentResourcePath, "resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), + "resourceProviderNamespace": resourceProviderNamespace, "resourceType": resourceType, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } @@ -755,7 +771,7 @@ func (client RoleAssignmentsClient) ListForResourceComplete(ctx context.Context, // ListForResourceGroup gets role assignments for a resource group. // Parameters: -// resourceGroupName - the name of the resource group. +// resourceGroupName - the name of the resource group. The name is case insensitive. // 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. @@ -770,6 +786,15 @@ func (client RoleAssignmentsClient) ListForResourceGroup(ctx context.Context, re tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.RoleAssignmentsClient", "ListForResourceGroup", err.Error()) + } + result.fn = client.listForResourceGroupNextResults req, err := client.ListForResourceGroupPreparer(ctx, resourceGroupName, filter) if err != nil { diff --git a/services/preview/authorization/mgmt/2018-01-01-preview/authorization/roledefinitions.go b/services/preview/authorization/mgmt/2018-01-01-preview/authorization/roledefinitions.go index d3ee5a13aca3..445a59445e3d 100644 --- a/services/preview/authorization/mgmt/2018-01-01-preview/authorization/roledefinitions.go +++ b/services/preview/authorization/mgmt/2018-01-01-preview/authorization/roledefinitions.go @@ -179,7 +179,7 @@ func (client RoleDefinitionsClient) DeleteSender(req *http.Request) (*http.Respo func (client RoleDefinitionsClient) DeleteResponder(resp *http.Response) (result RoleDefinition, err error) { err = autorest.Respond( resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} diff --git a/services/preview/authorization/mgmt/2018-07-01-preview/authorization/CHANGELOG.md b/services/preview/authorization/mgmt/2018-07-01-preview/authorization/CHANGELOG.md index 52911e4cc5e4..4140246fc17f 100644 --- a/services/preview/authorization/mgmt/2018-07-01-preview/authorization/CHANGELOG.md +++ b/services/preview/authorization/mgmt/2018-07-01-preview/authorization/CHANGELOG.md @@ -1,2 +1,27 @@ -# Change History +# Unreleased +## Breaking Changes + +### Removed Funcs + +1. Principal.MarshalJSON() ([]byte, error) + +## Additive Changes + +### New Funcs + +1. ErrorAdditionalInfo.MarshalJSON() ([]byte, error) +1. ErrorDetail.MarshalJSON() ([]byte, error) + +### Struct Changes + +#### New Structs + +1. ErrorAdditionalInfo +1. ErrorDetail +1. ErrorResponse + +#### New Struct Fields + +1. Principal.DisplayName +1. Principal.Email diff --git a/services/preview/authorization/mgmt/2018-07-01-preview/authorization/_meta.json b/services/preview/authorization/mgmt/2018-07-01-preview/authorization/_meta.json index 631c62195cd4..412699930348 100644 --- a/services/preview/authorization/mgmt/2018-07-01-preview/authorization/_meta.json +++ b/services/preview/authorization/mgmt/2018-07-01-preview/authorization/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "8bae7cfd0d36f34d22b22a8072acfd2a54861415", "readme": "/_/azure-rest-api-specs/specification/authorization/resource-manager/readme.md", "tag": "package-2018-07-01-preview", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/preview/authorization/mgmt/2018-07-01-preview/authorization/classicadministrators.go b/services/preview/authorization/mgmt/2018-07-01-preview/authorization/classicadministrators.go index 71dc9f3cdf7e..adb9c2979f8e 100644 --- a/services/preview/authorization/mgmt/2018-07-01-preview/authorization/classicadministrators.go +++ b/services/preview/authorization/mgmt/2018-07-01-preview/authorization/classicadministrators.go @@ -10,6 +10,7 @@ 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" ) @@ -43,6 +44,12 @@ func (client ClassicAdministratorsClient) List(ctx context.Context) (result Clas tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.ClassicAdministratorsClient", "List", err.Error()) + } + result.fn = client.listNextResults req, err := client.ListPreparer(ctx) if err != nil { diff --git a/services/preview/authorization/mgmt/2018-07-01-preview/authorization/denyassignments.go b/services/preview/authorization/mgmt/2018-07-01-preview/authorization/denyassignments.go index f5d7d0387994..a98e1d59fbc9 100644 --- a/services/preview/authorization/mgmt/2018-07-01-preview/authorization/denyassignments.go +++ b/services/preview/authorization/mgmt/2018-07-01-preview/authorization/denyassignments.go @@ -10,6 +10,7 @@ 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" ) @@ -203,6 +204,12 @@ func (client DenyAssignmentsClient) List(ctx context.Context, filter string) (re tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.DenyAssignmentsClient", "List", err.Error()) + } + result.fn = client.listNextResults req, err := client.ListPreparer(ctx, filter) if err != nil { @@ -309,7 +316,7 @@ func (client DenyAssignmentsClient) ListComplete(ctx context.Context, filter str // ListForResource gets deny assignments for a resource. // Parameters: -// resourceGroupName - the name of the resource group. +// resourceGroupName - the name of the resource group. The name is case insensitive. // resourceProviderNamespace - the namespace of the resource provider. // parentResourcePath - the parent resource identity. // resourceType - the resource type of the resource. @@ -334,6 +341,15 @@ func (client DenyAssignmentsClient) ListForResource(ctx context.Context, resourc tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.DenyAssignmentsClient", "ListForResource", err.Error()) + } + result.fn = client.listForResourceNextResults req, err := client.ListForResourcePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter) if err != nil { @@ -367,7 +383,7 @@ func (client DenyAssignmentsClient) ListForResourcePreparer(ctx context.Context, "parentResourcePath": parentResourcePath, "resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), + "resourceProviderNamespace": resourceProviderNamespace, "resourceType": resourceType, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } @@ -445,7 +461,7 @@ func (client DenyAssignmentsClient) ListForResourceComplete(ctx context.Context, // ListForResourceGroup gets deny assignments for a resource group. // Parameters: -// resourceGroupName - the name of the resource group. +// resourceGroupName - the name of the resource group. The name is case insensitive. // 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 @@ -466,6 +482,15 @@ func (client DenyAssignmentsClient) ListForResourceGroup(ctx context.Context, re tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.DenyAssignmentsClient", "ListForResourceGroup", err.Error()) + } + result.fn = client.listForResourceGroupNextResults req, err := client.ListForResourceGroupPreparer(ctx, resourceGroupName, filter) if err != nil { diff --git a/services/preview/authorization/mgmt/2018-07-01-preview/authorization/models.go b/services/preview/authorization/mgmt/2018-07-01-preview/authorization/models.go index 372185e3e843..b45cd0bcface 100644 --- a/services/preview/authorization/mgmt/2018-07-01-preview/authorization/models.go +++ b/services/preview/authorization/mgmt/2018-07-01-preview/authorization/models.go @@ -541,6 +541,47 @@ type DenyAssignmentProperties struct { IsSystemProtected *bool `json:"isSystemProtected,omitempty"` } +// ErrorAdditionalInfo the resource management error additional info. +type ErrorAdditionalInfo struct { + // Type - READ-ONLY; The additional info type. + Type *string `json:"type,omitempty"` + // Info - READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorAdditionalInfo. +func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorDetail the error detail. +type ErrorDetail struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The error target. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; The error details. + Details *[]ErrorDetail `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDetail. +func (ed ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorResponse common error response for all Azure Resource Manager APIs to return error details for +// failed operations. (This also follows the OData error response format.). +type ErrorResponse struct { + // Error - The error object. + Error *ErrorDetail `json:"error,omitempty"` +} + // Permission role definition permissions. type Permission struct { // Actions - Allowed actions. @@ -712,18 +753,16 @@ func NewPermissionGetResultPage(cur PermissionGetResult, getNextPage func(contex } } -// Principal deny assignment principal. +// Principal the name of the entity last modified it 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 - The id of the principal made changes 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. + // DisplayName - The name of the principal made changes + DisplayName *string `json:"displayName,omitempty"` + // Type - Type of principal such as user , group etc Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for Principal. -func (p Principal) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) + // Email - Email of principal + Email *string `json:"email,omitempty"` } // ProviderOperation operation diff --git a/services/preview/authorization/mgmt/2018-07-01-preview/authorization/permissions.go b/services/preview/authorization/mgmt/2018-07-01-preview/authorization/permissions.go index 62d87b8d120b..307f7a567df8 100644 --- a/services/preview/authorization/mgmt/2018-07-01-preview/authorization/permissions.go +++ b/services/preview/authorization/mgmt/2018-07-01-preview/authorization/permissions.go @@ -10,6 +10,7 @@ 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" ) @@ -32,7 +33,7 @@ func NewPermissionsClientWithBaseURI(baseURI string, subscriptionID string) Perm // ListForResource gets all permissions the caller has for a resource. // Parameters: -// resourceGroupName - the name of the resource group. +// resourceGroupName - the name of the resource group. The name is case insensitive. // resourceProviderNamespace - the namespace of the resource provider. // parentResourcePath - the parent resource identity. // resourceType - the resource type of the resource. @@ -48,6 +49,15 @@ func (client PermissionsClient) ListForResource(ctx context.Context, resourceGro tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.PermissionsClient", "ListForResource", err.Error()) + } + result.fn = client.listForResourceNextResults req, err := client.ListForResourcePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) if err != nil { @@ -81,7 +91,7 @@ func (client PermissionsClient) ListForResourcePreparer(ctx context.Context, res "parentResourcePath": parentResourcePath, "resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), + "resourceProviderNamespace": resourceProviderNamespace, "resourceType": resourceType, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } @@ -156,7 +166,7 @@ func (client PermissionsClient) ListForResourceComplete(ctx context.Context, res // ListForResourceGroup gets all permissions the caller has for a resource group. // Parameters: -// resourceGroupName - the name of the resource group. +// resourceGroupName - the name of the resource group. The name is case insensitive. func (client PermissionsClient) ListForResourceGroup(ctx context.Context, resourceGroupName string) (result PermissionGetResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListForResourceGroup") @@ -168,6 +178,15 @@ func (client PermissionsClient) ListForResourceGroup(ctx context.Context, resour tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.PermissionsClient", "ListForResourceGroup", err.Error()) + } + result.fn = client.listForResourceGroupNextResults req, err := client.ListForResourceGroupPreparer(ctx, resourceGroupName) if err != nil { diff --git a/services/preview/authorization/mgmt/2018-07-01-preview/authorization/provideroperationsmetadata.go b/services/preview/authorization/mgmt/2018-07-01-preview/authorization/provideroperationsmetadata.go index 359c843c0826..77cb8b9768e9 100644 --- a/services/preview/authorization/mgmt/2018-07-01-preview/authorization/provideroperationsmetadata.go +++ b/services/preview/authorization/mgmt/2018-07-01-preview/authorization/provideroperationsmetadata.go @@ -72,7 +72,7 @@ func (client ProviderOperationsMetadataClient) Get(ctx context.Context, resource // 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), + "resourceProviderNamespace": resourceProviderNamespace, } const APIVersion = "2018-01-01-preview" diff --git a/services/preview/authorization/mgmt/2018-07-01-preview/authorization/roleassignments.go b/services/preview/authorization/mgmt/2018-07-01-preview/authorization/roleassignments.go index bcfa975c050e..7b336b5c0750 100644 --- a/services/preview/authorization/mgmt/2018-07-01-preview/authorization/roleassignments.go +++ b/services/preview/authorization/mgmt/2018-07-01-preview/authorization/roleassignments.go @@ -38,7 +38,8 @@ func NewRoleAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) // '/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. +// roleAssignmentName - a GUID for the role assignment to create. The name must be unique and different for +// each role assignment. // 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() { @@ -275,7 +276,7 @@ func (client RoleAssignmentsClient) DeleteSender(req *http.Request) (*http.Respo func (client RoleAssignmentsClient) DeleteResponder(resp *http.Response) (result RoleAssignment, err error) { err = autorest.Respond( resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} @@ -348,7 +349,7 @@ func (client RoleAssignmentsClient) DeleteByIDSender(req *http.Request) (*http.R func (client RoleAssignmentsClient) DeleteByIDResponder(resp *http.Response) (result RoleAssignment, err error) { err = autorest.Respond( resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} @@ -519,6 +520,12 @@ func (client RoleAssignmentsClient) List(ctx context.Context, filter string) (re tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.RoleAssignmentsClient", "List", err.Error()) + } + result.fn = client.listNextResults req, err := client.ListPreparer(ctx, filter) if err != nil { @@ -625,7 +632,7 @@ func (client RoleAssignmentsClient) ListComplete(ctx context.Context, filter str // ListForResource gets role assignments for a resource. // Parameters: -// resourceGroupName - the name of the resource group. +// resourceGroupName - the name of the resource group. The name is case insensitive. // resourceProviderNamespace - the namespace of the resource provider. // parentResourcePath - the parent resource identity. // resourceType - the resource type of the resource. @@ -644,6 +651,15 @@ func (client RoleAssignmentsClient) ListForResource(ctx context.Context, resourc tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.RoleAssignmentsClient", "ListForResource", err.Error()) + } + result.fn = client.listForResourceNextResults req, err := client.ListForResourcePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter) if err != nil { @@ -677,7 +693,7 @@ func (client RoleAssignmentsClient) ListForResourcePreparer(ctx context.Context, "parentResourcePath": parentResourcePath, "resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), + "resourceProviderNamespace": resourceProviderNamespace, "resourceType": resourceType, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } @@ -755,7 +771,7 @@ func (client RoleAssignmentsClient) ListForResourceComplete(ctx context.Context, // ListForResourceGroup gets role assignments for a resource group. // Parameters: -// resourceGroupName - the name of the resource group. +// resourceGroupName - the name of the resource group. The name is case insensitive. // 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. @@ -770,6 +786,15 @@ func (client RoleAssignmentsClient) ListForResourceGroup(ctx context.Context, re tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.RoleAssignmentsClient", "ListForResourceGroup", err.Error()) + } + result.fn = client.listForResourceGroupNextResults req, err := client.ListForResourceGroupPreparer(ctx, resourceGroupName, filter) if err != nil { diff --git a/services/preview/authorization/mgmt/2018-07-01-preview/authorization/roledefinitions.go b/services/preview/authorization/mgmt/2018-07-01-preview/authorization/roledefinitions.go index d3ee5a13aca3..445a59445e3d 100644 --- a/services/preview/authorization/mgmt/2018-07-01-preview/authorization/roledefinitions.go +++ b/services/preview/authorization/mgmt/2018-07-01-preview/authorization/roledefinitions.go @@ -179,7 +179,7 @@ func (client RoleDefinitionsClient) DeleteSender(req *http.Request) (*http.Respo func (client RoleDefinitionsClient) DeleteResponder(resp *http.Response) (result RoleDefinition, err error) { err = autorest.Respond( resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} diff --git a/services/preview/authorization/mgmt/2018-09-01-preview/authorization/CHANGELOG.md b/services/preview/authorization/mgmt/2018-09-01-preview/authorization/CHANGELOG.md index 52911e4cc5e4..7ef2a39025c1 100644 --- a/services/preview/authorization/mgmt/2018-09-01-preview/authorization/CHANGELOG.md +++ b/services/preview/authorization/mgmt/2018-09-01-preview/authorization/CHANGELOG.md @@ -1,2 +1,36 @@ -# Change History +# Unreleased +## Breaking Changes + +### Removed Constants + +1. PrincipalType.Application +1. PrincipalType.DirectoryObjectOrGroup +1. PrincipalType.DirectoryRoleTemplate +1. PrincipalType.Everyone +1. PrincipalType.MSI +1. PrincipalType.Unknown + +### Removed Funcs + +1. Principal.MarshalJSON() ([]byte, error) + +## Additive Changes + +### New Funcs + +1. ErrorAdditionalInfo.MarshalJSON() ([]byte, error) +1. ErrorDetail.MarshalJSON() ([]byte, error) + +### Struct Changes + +#### New Structs + +1. ErrorAdditionalInfo +1. ErrorDetail +1. ErrorResponse + +#### New Struct Fields + +1. Principal.DisplayName +1. Principal.Email diff --git a/services/preview/authorization/mgmt/2018-09-01-preview/authorization/_meta.json b/services/preview/authorization/mgmt/2018-09-01-preview/authorization/_meta.json index 85da6e0a024c..9fc7cb8580ca 100644 --- a/services/preview/authorization/mgmt/2018-09-01-preview/authorization/_meta.json +++ b/services/preview/authorization/mgmt/2018-09-01-preview/authorization/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "8bae7cfd0d36f34d22b22a8072acfd2a54861415", "readme": "/_/azure-rest-api-specs/specification/authorization/resource-manager/readme.md", "tag": "package-2018-09-01-preview", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/preview/authorization/mgmt/2018-09-01-preview/authorization/classicadministrators.go b/services/preview/authorization/mgmt/2018-09-01-preview/authorization/classicadministrators.go index 71dc9f3cdf7e..adb9c2979f8e 100644 --- a/services/preview/authorization/mgmt/2018-09-01-preview/authorization/classicadministrators.go +++ b/services/preview/authorization/mgmt/2018-09-01-preview/authorization/classicadministrators.go @@ -10,6 +10,7 @@ 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" ) @@ -43,6 +44,12 @@ func (client ClassicAdministratorsClient) List(ctx context.Context) (result Clas tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.ClassicAdministratorsClient", "List", err.Error()) + } + result.fn = client.listNextResults req, err := client.ListPreparer(ctx) if err != nil { diff --git a/services/preview/authorization/mgmt/2018-09-01-preview/authorization/denyassignments.go b/services/preview/authorization/mgmt/2018-09-01-preview/authorization/denyassignments.go index f5d7d0387994..a98e1d59fbc9 100644 --- a/services/preview/authorization/mgmt/2018-09-01-preview/authorization/denyassignments.go +++ b/services/preview/authorization/mgmt/2018-09-01-preview/authorization/denyassignments.go @@ -10,6 +10,7 @@ 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" ) @@ -203,6 +204,12 @@ func (client DenyAssignmentsClient) List(ctx context.Context, filter string) (re tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.DenyAssignmentsClient", "List", err.Error()) + } + result.fn = client.listNextResults req, err := client.ListPreparer(ctx, filter) if err != nil { @@ -309,7 +316,7 @@ func (client DenyAssignmentsClient) ListComplete(ctx context.Context, filter str // ListForResource gets deny assignments for a resource. // Parameters: -// resourceGroupName - the name of the resource group. +// resourceGroupName - the name of the resource group. The name is case insensitive. // resourceProviderNamespace - the namespace of the resource provider. // parentResourcePath - the parent resource identity. // resourceType - the resource type of the resource. @@ -334,6 +341,15 @@ func (client DenyAssignmentsClient) ListForResource(ctx context.Context, resourc tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.DenyAssignmentsClient", "ListForResource", err.Error()) + } + result.fn = client.listForResourceNextResults req, err := client.ListForResourcePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter) if err != nil { @@ -367,7 +383,7 @@ func (client DenyAssignmentsClient) ListForResourcePreparer(ctx context.Context, "parentResourcePath": parentResourcePath, "resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), + "resourceProviderNamespace": resourceProviderNamespace, "resourceType": resourceType, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } @@ -445,7 +461,7 @@ func (client DenyAssignmentsClient) ListForResourceComplete(ctx context.Context, // ListForResourceGroup gets deny assignments for a resource group. // Parameters: -// resourceGroupName - the name of the resource group. +// resourceGroupName - the name of the resource group. The name is case insensitive. // 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 @@ -466,6 +482,15 @@ func (client DenyAssignmentsClient) ListForResourceGroup(ctx context.Context, re tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.DenyAssignmentsClient", "ListForResourceGroup", err.Error()) + } + result.fn = client.listForResourceGroupNextResults req, err := client.ListForResourceGroupPreparer(ctx, resourceGroupName, filter) if err != nil { diff --git a/services/preview/authorization/mgmt/2018-09-01-preview/authorization/enums.go b/services/preview/authorization/mgmt/2018-09-01-preview/authorization/enums.go index f0c637120a4f..55e1d9d6aac0 100644 --- a/services/preview/authorization/mgmt/2018-09-01-preview/authorization/enums.go +++ b/services/preview/authorization/mgmt/2018-09-01-preview/authorization/enums.go @@ -10,29 +10,17 @@ package authorization 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} + return []PrincipalType{ForeignGroup, Group, ServicePrincipal, User} } diff --git a/services/preview/authorization/mgmt/2018-09-01-preview/authorization/models.go b/services/preview/authorization/mgmt/2018-09-01-preview/authorization/models.go index f4fb758e8ad7..5d2167267336 100644 --- a/services/preview/authorization/mgmt/2018-09-01-preview/authorization/models.go +++ b/services/preview/authorization/mgmt/2018-09-01-preview/authorization/models.go @@ -541,6 +541,47 @@ type DenyAssignmentProperties struct { IsSystemProtected *bool `json:"isSystemProtected,omitempty"` } +// ErrorAdditionalInfo the resource management error additional info. +type ErrorAdditionalInfo struct { + // Type - READ-ONLY; The additional info type. + Type *string `json:"type,omitempty"` + // Info - READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorAdditionalInfo. +func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorDetail the error detail. +type ErrorDetail struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The error target. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; The error details. + Details *[]ErrorDetail `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDetail. +func (ed ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorResponse common error response for all Azure Resource Manager APIs to return error details for +// failed operations. (This also follows the OData error response format.). +type ErrorResponse struct { + // Error - The error object. + Error *ErrorDetail `json:"error,omitempty"` +} + // Permission role definition permissions. type Permission struct { // Actions - Allowed actions. @@ -712,18 +753,16 @@ func NewPermissionGetResultPage(cur PermissionGetResult, getNextPage func(contex } } -// Principal deny assignment principal. +// Principal the name of the entity last modified it 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 - The id of the principal made changes 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. + // DisplayName - The name of the principal made changes + DisplayName *string `json:"displayName,omitempty"` + // Type - Type of principal such as user , group etc Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for Principal. -func (p Principal) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) + // Email - Email of principal + Email *string `json:"email,omitempty"` } // ProviderOperation operation @@ -1214,7 +1253,7 @@ type RoleAssignmentProperties struct { 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 - The principal type of the assigned principal ID. Possible values include: 'User', 'Group', 'ServicePrincipal', 'ForeignGroup' PrincipalType PrincipalType `json:"principalType,omitempty"` // CanDelegate - The delegation flag used for creating a role assignment CanDelegate *bool `json:"canDelegate,omitempty"` @@ -1228,7 +1267,7 @@ type RoleAssignmentPropertiesWithScope struct { 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 - The principal type of the assigned principal ID. Possible values include: 'User', 'Group', 'ServicePrincipal', 'ForeignGroup' PrincipalType PrincipalType `json:"principalType,omitempty"` // CanDelegate - The Delegation flag for the role assignment CanDelegate *bool `json:"canDelegate,omitempty"` diff --git a/services/preview/authorization/mgmt/2018-09-01-preview/authorization/permissions.go b/services/preview/authorization/mgmt/2018-09-01-preview/authorization/permissions.go index 62d87b8d120b..307f7a567df8 100644 --- a/services/preview/authorization/mgmt/2018-09-01-preview/authorization/permissions.go +++ b/services/preview/authorization/mgmt/2018-09-01-preview/authorization/permissions.go @@ -10,6 +10,7 @@ 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" ) @@ -32,7 +33,7 @@ func NewPermissionsClientWithBaseURI(baseURI string, subscriptionID string) Perm // ListForResource gets all permissions the caller has for a resource. // Parameters: -// resourceGroupName - the name of the resource group. +// resourceGroupName - the name of the resource group. The name is case insensitive. // resourceProviderNamespace - the namespace of the resource provider. // parentResourcePath - the parent resource identity. // resourceType - the resource type of the resource. @@ -48,6 +49,15 @@ func (client PermissionsClient) ListForResource(ctx context.Context, resourceGro tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.PermissionsClient", "ListForResource", err.Error()) + } + result.fn = client.listForResourceNextResults req, err := client.ListForResourcePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) if err != nil { @@ -81,7 +91,7 @@ func (client PermissionsClient) ListForResourcePreparer(ctx context.Context, res "parentResourcePath": parentResourcePath, "resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), + "resourceProviderNamespace": resourceProviderNamespace, "resourceType": resourceType, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } @@ -156,7 +166,7 @@ func (client PermissionsClient) ListForResourceComplete(ctx context.Context, res // ListForResourceGroup gets all permissions the caller has for a resource group. // Parameters: -// resourceGroupName - the name of the resource group. +// resourceGroupName - the name of the resource group. The name is case insensitive. func (client PermissionsClient) ListForResourceGroup(ctx context.Context, resourceGroupName string) (result PermissionGetResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListForResourceGroup") @@ -168,6 +178,15 @@ func (client PermissionsClient) ListForResourceGroup(ctx context.Context, resour tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.PermissionsClient", "ListForResourceGroup", err.Error()) + } + result.fn = client.listForResourceGroupNextResults req, err := client.ListForResourceGroupPreparer(ctx, resourceGroupName) if err != nil { diff --git a/services/preview/authorization/mgmt/2018-09-01-preview/authorization/provideroperationsmetadata.go b/services/preview/authorization/mgmt/2018-09-01-preview/authorization/provideroperationsmetadata.go index 359c843c0826..77cb8b9768e9 100644 --- a/services/preview/authorization/mgmt/2018-09-01-preview/authorization/provideroperationsmetadata.go +++ b/services/preview/authorization/mgmt/2018-09-01-preview/authorization/provideroperationsmetadata.go @@ -72,7 +72,7 @@ func (client ProviderOperationsMetadataClient) Get(ctx context.Context, resource // 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), + "resourceProviderNamespace": resourceProviderNamespace, } const APIVersion = "2018-01-01-preview" diff --git a/services/preview/authorization/mgmt/2018-09-01-preview/authorization/roleassignments.go b/services/preview/authorization/mgmt/2018-09-01-preview/authorization/roleassignments.go index ea9b915211a1..221688361834 100644 --- a/services/preview/authorization/mgmt/2018-09-01-preview/authorization/roleassignments.go +++ b/services/preview/authorization/mgmt/2018-09-01-preview/authorization/roleassignments.go @@ -38,7 +38,8 @@ func NewRoleAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) // '/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. +// roleAssignmentName - a GUID for the role assignment to create. The name must be unique and different for +// each role assignment. // 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() { @@ -275,7 +276,7 @@ func (client RoleAssignmentsClient) DeleteSender(req *http.Request) (*http.Respo func (client RoleAssignmentsClient) DeleteResponder(resp *http.Response) (result RoleAssignment, err error) { err = autorest.Respond( resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} @@ -348,7 +349,7 @@ func (client RoleAssignmentsClient) DeleteByIDSender(req *http.Request) (*http.R func (client RoleAssignmentsClient) DeleteByIDResponder(resp *http.Response) (result RoleAssignment, err error) { err = autorest.Respond( resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} @@ -519,6 +520,12 @@ func (client RoleAssignmentsClient) List(ctx context.Context, filter string) (re tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.RoleAssignmentsClient", "List", err.Error()) + } + result.fn = client.listNextResults req, err := client.ListPreparer(ctx, filter) if err != nil { @@ -625,7 +632,7 @@ func (client RoleAssignmentsClient) ListComplete(ctx context.Context, filter str // ListForResource gets role assignments for a resource. // Parameters: -// resourceGroupName - the name of the resource group. +// resourceGroupName - the name of the resource group. The name is case insensitive. // resourceProviderNamespace - the namespace of the resource provider. // parentResourcePath - the parent resource identity. // resourceType - the resource type of the resource. @@ -644,6 +651,15 @@ func (client RoleAssignmentsClient) ListForResource(ctx context.Context, resourc tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.RoleAssignmentsClient", "ListForResource", err.Error()) + } + result.fn = client.listForResourceNextResults req, err := client.ListForResourcePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter) if err != nil { @@ -677,7 +693,7 @@ func (client RoleAssignmentsClient) ListForResourcePreparer(ctx context.Context, "parentResourcePath": parentResourcePath, "resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), + "resourceProviderNamespace": resourceProviderNamespace, "resourceType": resourceType, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } @@ -755,7 +771,7 @@ func (client RoleAssignmentsClient) ListForResourceComplete(ctx context.Context, // ListForResourceGroup gets role assignments for a resource group. // Parameters: -// resourceGroupName - the name of the resource group. +// resourceGroupName - the name of the resource group. The name is case insensitive. // 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. @@ -770,6 +786,15 @@ func (client RoleAssignmentsClient) ListForResourceGroup(ctx context.Context, re tracing.EndSpan(ctx, sc, err) }() } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.RoleAssignmentsClient", "ListForResourceGroup", err.Error()) + } + result.fn = client.listForResourceGroupNextResults req, err := client.ListForResourceGroupPreparer(ctx, resourceGroupName, filter) if err != nil { diff --git a/services/preview/authorization/mgmt/2018-09-01-preview/authorization/roledefinitions.go b/services/preview/authorization/mgmt/2018-09-01-preview/authorization/roledefinitions.go index d3ee5a13aca3..445a59445e3d 100644 --- a/services/preview/authorization/mgmt/2018-09-01-preview/authorization/roledefinitions.go +++ b/services/preview/authorization/mgmt/2018-09-01-preview/authorization/roledefinitions.go @@ -179,7 +179,7 @@ func (client RoleDefinitionsClient) DeleteSender(req *http.Request) (*http.Respo func (client RoleDefinitionsClient) DeleteResponder(resp *http.Response) (result RoleDefinition, err error) { err = autorest.Respond( resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} diff --git a/services/preview/authorization/mgmt/2020-04-01-preview/authorization/CHANGELOG.md b/services/preview/authorization/mgmt/2020-04-01-preview/authorization/CHANGELOG.md index 52911e4cc5e4..8f6597894ba6 100644 --- a/services/preview/authorization/mgmt/2020-04-01-preview/authorization/CHANGELOG.md +++ b/services/preview/authorization/mgmt/2020-04-01-preview/authorization/CHANGELOG.md @@ -1,2 +1,25 @@ -# Change History +# Unreleased +## Breaking Changes + +### Removed Constants + +1. PrincipalType.Application +1. PrincipalType.DirectoryObjectOrGroup +1. PrincipalType.DirectoryRoleTemplate +1. PrincipalType.Everyone +1. PrincipalType.MSI +1. PrincipalType.Unknown + +### Removed Funcs + +1. Principal.MarshalJSON() ([]byte, error) + +## Additive Changes + +### Struct Changes + +#### New Struct Fields + +1. Principal.DisplayName +1. Principal.Email diff --git a/services/preview/authorization/mgmt/2020-04-01-preview/authorization/_meta.json b/services/preview/authorization/mgmt/2020-04-01-preview/authorization/_meta.json index ffda37794b41..b7c2b9b186ae 100644 --- a/services/preview/authorization/mgmt/2020-04-01-preview/authorization/_meta.json +++ b/services/preview/authorization/mgmt/2020-04-01-preview/authorization/_meta.json @@ -1,5 +1,5 @@ { - "commit": "5fcc6854765009e891052653b304cfe80353430a", + "commit": "8bae7cfd0d36f34d22b22a8072acfd2a54861415", "readme": "/_/azure-rest-api-specs/specification/authorization/resource-manager/readme.md", "tag": "package-2020-04-01-preview", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/preview/authorization/mgmt/2020-04-01-preview/authorization/denyassignments.go b/services/preview/authorization/mgmt/2020-04-01-preview/authorization/denyassignments.go index c2a2800232db..a98e1d59fbc9 100644 --- a/services/preview/authorization/mgmt/2020-04-01-preview/authorization/denyassignments.go +++ b/services/preview/authorization/mgmt/2020-04-01-preview/authorization/denyassignments.go @@ -346,8 +346,7 @@ func (client DenyAssignmentsClient) ListForResource(ctx context.Context, resourc Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("authorization.DenyAssignmentsClient", "ListForResource", err.Error()) } @@ -384,7 +383,7 @@ func (client DenyAssignmentsClient) ListForResourcePreparer(ctx context.Context, "parentResourcePath": parentResourcePath, "resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), + "resourceProviderNamespace": resourceProviderNamespace, "resourceType": resourceType, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } @@ -488,8 +487,7 @@ func (client DenyAssignmentsClient) ListForResourceGroup(ctx context.Context, re Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("authorization.DenyAssignmentsClient", "ListForResourceGroup", err.Error()) } diff --git a/services/preview/authorization/mgmt/2020-04-01-preview/authorization/enums.go b/services/preview/authorization/mgmt/2020-04-01-preview/authorization/enums.go index f0c637120a4f..55e1d9d6aac0 100644 --- a/services/preview/authorization/mgmt/2020-04-01-preview/authorization/enums.go +++ b/services/preview/authorization/mgmt/2020-04-01-preview/authorization/enums.go @@ -10,29 +10,17 @@ package authorization 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} + return []PrincipalType{ForeignGroup, Group, ServicePrincipal, User} } diff --git a/services/preview/authorization/mgmt/2020-04-01-preview/authorization/models.go b/services/preview/authorization/mgmt/2020-04-01-preview/authorization/models.go index 20d9e396b809..95bc850ee417 100644 --- a/services/preview/authorization/mgmt/2020-04-01-preview/authorization/models.go +++ b/services/preview/authorization/mgmt/2020-04-01-preview/authorization/models.go @@ -754,18 +754,16 @@ func NewPermissionGetResultPage(cur PermissionGetResult, getNextPage func(contex } } -// Principal deny assignment principal. +// Principal the name of the entity last modified it 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 - The id of the principal made changes 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. + // DisplayName - The name of the principal made changes + DisplayName *string `json:"displayName,omitempty"` + // Type - Type of principal such as user , group etc Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for Principal. -func (p Principal) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) + // Email - Email of principal + Email *string `json:"email,omitempty"` } // ProviderOperation operation @@ -1275,7 +1273,7 @@ type RoleAssignmentProperties struct { 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 - The principal type of the assigned principal ID. Possible values include: 'User', 'Group', 'ServicePrincipal', 'ForeignGroup' PrincipalType PrincipalType `json:"principalType,omitempty"` // CanDelegate - The delegation flag used for creating a role assignment CanDelegate *bool `json:"canDelegate,omitempty"` @@ -1297,7 +1295,7 @@ type RoleAssignmentPropertiesWithScope struct { 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 - The principal type of the assigned principal ID. Possible values include: 'User', 'Group', 'ServicePrincipal', 'ForeignGroup' PrincipalType PrincipalType `json:"principalType,omitempty"` // CanDelegate - The Delegation flag for the role assignment CanDelegate *bool `json:"canDelegate,omitempty"` diff --git a/services/preview/authorization/mgmt/2020-04-01-preview/authorization/permissions.go b/services/preview/authorization/mgmt/2020-04-01-preview/authorization/permissions.go index 8c6135300b5f..307f7a567df8 100644 --- a/services/preview/authorization/mgmt/2020-04-01-preview/authorization/permissions.go +++ b/services/preview/authorization/mgmt/2020-04-01-preview/authorization/permissions.go @@ -52,8 +52,7 @@ func (client PermissionsClient) ListForResource(ctx context.Context, resourceGro if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: client.SubscriptionID, Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("authorization.PermissionsClient", "ListForResource", err.Error()) @@ -92,7 +91,7 @@ func (client PermissionsClient) ListForResourcePreparer(ctx context.Context, res "parentResourcePath": parentResourcePath, "resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), + "resourceProviderNamespace": resourceProviderNamespace, "resourceType": resourceType, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } @@ -182,8 +181,7 @@ func (client PermissionsClient) ListForResourceGroup(ctx context.Context, resour if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: client.SubscriptionID, Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("authorization.PermissionsClient", "ListForResourceGroup", err.Error()) diff --git a/services/preview/authorization/mgmt/2020-04-01-preview/authorization/provideroperationsmetadata.go b/services/preview/authorization/mgmt/2020-04-01-preview/authorization/provideroperationsmetadata.go index 359c843c0826..77cb8b9768e9 100644 --- a/services/preview/authorization/mgmt/2020-04-01-preview/authorization/provideroperationsmetadata.go +++ b/services/preview/authorization/mgmt/2020-04-01-preview/authorization/provideroperationsmetadata.go @@ -72,7 +72,7 @@ func (client ProviderOperationsMetadataClient) Get(ctx context.Context, resource // 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), + "resourceProviderNamespace": resourceProviderNamespace, } const APIVersion = "2018-01-01-preview" diff --git a/services/preview/authorization/mgmt/2020-04-01-preview/authorization/roleassignments.go b/services/preview/authorization/mgmt/2020-04-01-preview/authorization/roleassignments.go index 53a25d6a5ae5..cc1ea1a25b46 100644 --- a/services/preview/authorization/mgmt/2020-04-01-preview/authorization/roleassignments.go +++ b/services/preview/authorization/mgmt/2020-04-01-preview/authorization/roleassignments.go @@ -38,7 +38,8 @@ func NewRoleAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) // '/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. +// roleAssignmentName - a GUID for the role assignment to create. The name must be unique and different for +// each role assignment. // 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() { @@ -674,8 +675,7 @@ func (client RoleAssignmentsClient) ListForResource(ctx context.Context, resourc if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: client.SubscriptionID, Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("authorization.RoleAssignmentsClient", "ListForResource", err.Error()) @@ -714,7 +714,7 @@ func (client RoleAssignmentsClient) ListForResourcePreparer(ctx context.Context, "parentResourcePath": parentResourcePath, "resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), + "resourceProviderNamespace": resourceProviderNamespace, "resourceType": resourceType, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } @@ -814,8 +814,7 @@ func (client RoleAssignmentsClient) ListForResourceGroup(ctx context.Context, re if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: client.SubscriptionID, Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("authorization.RoleAssignmentsClient", "ListForResourceGroup", err.Error()) diff --git a/services/preview/authorization/mgmt/2020-10-01-preview/authorization/CHANGELOG.md b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/CHANGELOG.md new file mode 100644 index 000000000000..a1ecf841edb0 --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/CHANGELOG.md @@ -0,0 +1,2 @@ +# Unreleased + diff --git a/services/preview/authorization/mgmt/2020-10-01-preview/authorization/_meta.json b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/_meta.json new file mode 100644 index 000000000000..7ac67d383f15 --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "8bae7cfd0d36f34d22b22a8072acfd2a54861415", + "readme": "/_/azure-rest-api-specs/specification/authorization/resource-manager/readme.md", + "tag": "package-2020-10-01-preview", + "use": "@microsoft.azure/autorest.go@2.1.187", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-2020-10-01-preview --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/authorization/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION" + } +} \ No newline at end of file diff --git a/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewdefaultsettings.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewdefaultsettings.go new file mode 100644 index 000000000000..f876eb68c27a --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewdefaultsettings.go @@ -0,0 +1,192 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AccessReviewDefaultSettingsClient is the client for the AccessReviewDefaultSettings methods of the Authorization +// service. +type AccessReviewDefaultSettingsClient struct { + BaseClient +} + +// NewAccessReviewDefaultSettingsClient creates an instance of the AccessReviewDefaultSettingsClient client. +func NewAccessReviewDefaultSettingsClient(subscriptionID string) AccessReviewDefaultSettingsClient { + return NewAccessReviewDefaultSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAccessReviewDefaultSettingsClientWithBaseURI creates an instance of the AccessReviewDefaultSettingsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewAccessReviewDefaultSettingsClientWithBaseURI(baseURI string, subscriptionID string) AccessReviewDefaultSettingsClient { + return AccessReviewDefaultSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get access review default settings for the subscription +func (client AccessReviewDefaultSettingsClient) Get(ctx context.Context) (result AccessReviewDefaultSettings, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewDefaultSettingsClient.Get") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.AccessReviewDefaultSettingsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewDefaultSettingsClient", "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.AccessReviewDefaultSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewDefaultSettingsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client AccessReviewDefaultSettingsClient) GetPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default", 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 AccessReviewDefaultSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AccessReviewDefaultSettingsClient) GetResponder(resp *http.Response) (result AccessReviewDefaultSettings, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Put get access review default settings for the subscription +// Parameters: +// properties - access review schedule settings. +func (client AccessReviewDefaultSettingsClient) Put(ctx context.Context, properties AccessReviewScheduleSettings) (result AccessReviewDefaultSettings, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewDefaultSettingsClient.Put") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.AccessReviewDefaultSettingsClient", "Put", err.Error()) + } + + req, err := client.PutPreparer(ctx, properties) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewDefaultSettingsClient", "Put", nil, "Failure preparing request") + return + } + + resp, err := client.PutSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.AccessReviewDefaultSettingsClient", "Put", resp, "Failure sending request") + return + } + + result, err = client.PutResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewDefaultSettingsClient", "Put", resp, "Failure responding to request") + return + } + + return +} + +// PutPreparer prepares the Put request. +func (client AccessReviewDefaultSettingsClient) PutPreparer(ctx context.Context, properties AccessReviewScheduleSettings) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-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("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default", pathParameters), + autorest.WithJSON(properties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PutSender sends the Put request. The method will close the +// http.Response Body if it receives an error. +func (client AccessReviewDefaultSettingsClient) PutSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// PutResponder handles the response to the Put request. The method always +// closes the http.Response Body. +func (client AccessReviewDefaultSettingsClient) PutResponder(resp *http.Response) (result AccessReviewDefaultSettings, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewinstance.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewinstance.go new file mode 100644 index 000000000000..73c9b02c0223 --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewinstance.go @@ -0,0 +1,431 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AccessReviewInstanceClient is the client for the AccessReviewInstance methods of the Authorization service. +type AccessReviewInstanceClient struct { + BaseClient +} + +// NewAccessReviewInstanceClient creates an instance of the AccessReviewInstanceClient client. +func NewAccessReviewInstanceClient(subscriptionID string) AccessReviewInstanceClient { + return NewAccessReviewInstanceClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAccessReviewInstanceClientWithBaseURI creates an instance of the AccessReviewInstanceClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewAccessReviewInstanceClientWithBaseURI(baseURI string, subscriptionID string) AccessReviewInstanceClient { + return AccessReviewInstanceClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// AcceptRecommendations an action to accept recommendations for decision in an access review instance. +// Parameters: +// scheduleDefinitionID - the id of the access review schedule definition. +// ID - the id of the access review instance. +func (client AccessReviewInstanceClient) AcceptRecommendations(ctx context.Context, scheduleDefinitionID string, ID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewInstanceClient.AcceptRecommendations") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.AcceptRecommendationsPreparer(ctx, scheduleDefinitionID, ID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceClient", "AcceptRecommendations", nil, "Failure preparing request") + return + } + + resp, err := client.AcceptRecommendationsSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceClient", "AcceptRecommendations", resp, "Failure sending request") + return + } + + result, err = client.AcceptRecommendationsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceClient", "AcceptRecommendations", resp, "Failure responding to request") + return + } + + return +} + +// AcceptRecommendationsPreparer prepares the AcceptRecommendations request. +func (client AccessReviewInstanceClient) AcceptRecommendationsPreparer(ctx context.Context, scheduleDefinitionID string, ID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "id": autorest.Encode("path", ID), + "scheduleDefinitionId": autorest.Encode("path", scheduleDefinitionID), + } + + const APIVersion = "2018-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// AcceptRecommendationsSender sends the AcceptRecommendations request. The method will close the +// http.Response Body if it receives an error. +func (client AccessReviewInstanceClient) AcceptRecommendationsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// AcceptRecommendationsResponder handles the response to the AcceptRecommendations request. The method always +// closes the http.Response Body. +func (client AccessReviewInstanceClient) AcceptRecommendationsResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// ApplyDecisions an action to apply all decisions for an access review instance. +// Parameters: +// scheduleDefinitionID - the id of the access review schedule definition. +// ID - the id of the access review instance. +func (client AccessReviewInstanceClient) ApplyDecisions(ctx context.Context, scheduleDefinitionID string, ID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewInstanceClient.ApplyDecisions") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.AccessReviewInstanceClient", "ApplyDecisions", err.Error()) + } + + req, err := client.ApplyDecisionsPreparer(ctx, scheduleDefinitionID, ID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceClient", "ApplyDecisions", nil, "Failure preparing request") + return + } + + resp, err := client.ApplyDecisionsSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceClient", "ApplyDecisions", resp, "Failure sending request") + return + } + + result, err = client.ApplyDecisionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceClient", "ApplyDecisions", resp, "Failure responding to request") + return + } + + return +} + +// ApplyDecisionsPreparer prepares the ApplyDecisions request. +func (client AccessReviewInstanceClient) ApplyDecisionsPreparer(ctx context.Context, scheduleDefinitionID string, ID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "id": autorest.Encode("path", ID), + "scheduleDefinitionId": autorest.Encode("path", scheduleDefinitionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ApplyDecisionsSender sends the ApplyDecisions request. The method will close the +// http.Response Body if it receives an error. +func (client AccessReviewInstanceClient) ApplyDecisionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ApplyDecisionsResponder handles the response to the ApplyDecisions request. The method always +// closes the http.Response Body. +func (client AccessReviewInstanceClient) ApplyDecisionsResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// ResetDecisions an action to reset all decisions for an access review instance. +// Parameters: +// scheduleDefinitionID - the id of the access review schedule definition. +// ID - the id of the access review instance. +func (client AccessReviewInstanceClient) ResetDecisions(ctx context.Context, scheduleDefinitionID string, ID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewInstanceClient.ResetDecisions") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.AccessReviewInstanceClient", "ResetDecisions", err.Error()) + } + + req, err := client.ResetDecisionsPreparer(ctx, scheduleDefinitionID, ID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceClient", "ResetDecisions", nil, "Failure preparing request") + return + } + + resp, err := client.ResetDecisionsSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceClient", "ResetDecisions", resp, "Failure sending request") + return + } + + result, err = client.ResetDecisionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceClient", "ResetDecisions", resp, "Failure responding to request") + return + } + + return +} + +// ResetDecisionsPreparer prepares the ResetDecisions request. +func (client AccessReviewInstanceClient) ResetDecisionsPreparer(ctx context.Context, scheduleDefinitionID string, ID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "id": autorest.Encode("path", ID), + "scheduleDefinitionId": autorest.Encode("path", scheduleDefinitionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ResetDecisionsSender sends the ResetDecisions request. The method will close the +// http.Response Body if it receives an error. +func (client AccessReviewInstanceClient) ResetDecisionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ResetDecisionsResponder handles the response to the ResetDecisions request. The method always +// closes the http.Response Body. +func (client AccessReviewInstanceClient) ResetDecisionsResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// SendReminders an action to send reminders for an access review instance. +// Parameters: +// scheduleDefinitionID - the id of the access review schedule definition. +// ID - the id of the access review instance. +func (client AccessReviewInstanceClient) SendReminders(ctx context.Context, scheduleDefinitionID string, ID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewInstanceClient.SendReminders") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.AccessReviewInstanceClient", "SendReminders", err.Error()) + } + + req, err := client.SendRemindersPreparer(ctx, scheduleDefinitionID, ID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceClient", "SendReminders", nil, "Failure preparing request") + return + } + + resp, err := client.SendRemindersSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceClient", "SendReminders", resp, "Failure sending request") + return + } + + result, err = client.SendRemindersResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceClient", "SendReminders", resp, "Failure responding to request") + return + } + + return +} + +// SendRemindersPreparer prepares the SendReminders request. +func (client AccessReviewInstanceClient) SendRemindersPreparer(ctx context.Context, scheduleDefinitionID string, ID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "id": autorest.Encode("path", ID), + "scheduleDefinitionId": autorest.Encode("path", scheduleDefinitionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// SendRemindersSender sends the SendReminders request. The method will close the +// http.Response Body if it receives an error. +func (client AccessReviewInstanceClient) SendRemindersSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// SendRemindersResponder handles the response to the SendReminders request. The method always +// closes the http.Response Body. +func (client AccessReviewInstanceClient) SendRemindersResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Stop an action to stop an access review instance. +// Parameters: +// scheduleDefinitionID - the id of the access review schedule definition. +// ID - the id of the access review instance. +func (client AccessReviewInstanceClient) Stop(ctx context.Context, scheduleDefinitionID string, ID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewInstanceClient.Stop") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.AccessReviewInstanceClient", "Stop", err.Error()) + } + + req, err := client.StopPreparer(ctx, scheduleDefinitionID, ID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceClient", "Stop", nil, "Failure preparing request") + return + } + + resp, err := client.StopSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceClient", "Stop", resp, "Failure sending request") + return + } + + result, err = client.StopResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceClient", "Stop", resp, "Failure responding to request") + return + } + + return +} + +// StopPreparer prepares the Stop request. +func (client AccessReviewInstanceClient) StopPreparer(ctx context.Context, scheduleDefinitionID string, ID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "id": autorest.Encode("path", ID), + "scheduleDefinitionId": autorest.Encode("path", scheduleDefinitionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StopSender sends the Stop request. The method will close the +// http.Response Body if it receives an error. +func (client AccessReviewInstanceClient) StopSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// StopResponder handles the response to the Stop request. The method always +// closes the http.Response Body. +func (client AccessReviewInstanceClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewinstancedecisions.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewinstancedecisions.go new file mode 100644 index 000000000000..172ecff25b28 --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewinstancedecisions.go @@ -0,0 +1,158 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AccessReviewInstanceDecisionsClient is the client for the AccessReviewInstanceDecisions methods of the Authorization +// service. +type AccessReviewInstanceDecisionsClient struct { + BaseClient +} + +// NewAccessReviewInstanceDecisionsClient creates an instance of the AccessReviewInstanceDecisionsClient client. +func NewAccessReviewInstanceDecisionsClient(subscriptionID string) AccessReviewInstanceDecisionsClient { + return NewAccessReviewInstanceDecisionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAccessReviewInstanceDecisionsClientWithBaseURI creates an instance of the AccessReviewInstanceDecisionsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewAccessReviewInstanceDecisionsClientWithBaseURI(baseURI string, subscriptionID string) AccessReviewInstanceDecisionsClient { + return AccessReviewInstanceDecisionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List get access review instance decisions +// Parameters: +// scheduleDefinitionID - the id of the access review schedule definition. +// ID - the id of the access review instance. +func (client AccessReviewInstanceDecisionsClient) List(ctx context.Context, scheduleDefinitionID string, ID string) (result AccessReviewDecisionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewInstanceDecisionsClient.List") + defer func() { + sc := -1 + if result.ardlr.Response.Response != nil { + sc = result.ardlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.AccessReviewInstanceDecisionsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, scheduleDefinitionID, ID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceDecisionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ardlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceDecisionsClient", "List", resp, "Failure sending request") + return + } + + result.ardlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceDecisionsClient", "List", resp, "Failure responding to request") + return + } + if result.ardlr.hasNextLink() && result.ardlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client AccessReviewInstanceDecisionsClient) ListPreparer(ctx context.Context, scheduleDefinitionID string, ID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "id": autorest.Encode("path", ID), + "scheduleDefinitionId": autorest.Encode("path", scheduleDefinitionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions", 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 AccessReviewInstanceDecisionsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AccessReviewInstanceDecisionsClient) ListResponder(resp *http.Response) (result AccessReviewDecisionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AccessReviewInstanceDecisionsClient) listNextResults(ctx context.Context, lastResults AccessReviewDecisionListResult) (result AccessReviewDecisionListResult, err error) { + req, err := lastResults.accessReviewDecisionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceDecisionsClient", "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.AccessReviewInstanceDecisionsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceDecisionsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AccessReviewInstanceDecisionsClient) ListComplete(ctx context.Context, scheduleDefinitionID string, ID string) (result AccessReviewDecisionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewInstanceDecisionsClient.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, scheduleDefinitionID, ID) + return +} diff --git a/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewinstancemydecisions.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewinstancemydecisions.go new file mode 100644 index 000000000000..dafebcad28f8 --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewinstancemydecisions.go @@ -0,0 +1,314 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AccessReviewInstanceMyDecisionsClient is the client for the AccessReviewInstanceMyDecisions methods of the +// Authorization service. +type AccessReviewInstanceMyDecisionsClient struct { + BaseClient +} + +// NewAccessReviewInstanceMyDecisionsClient creates an instance of the AccessReviewInstanceMyDecisionsClient client. +func NewAccessReviewInstanceMyDecisionsClient(subscriptionID string) AccessReviewInstanceMyDecisionsClient { + return NewAccessReviewInstanceMyDecisionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAccessReviewInstanceMyDecisionsClientWithBaseURI creates an instance of the AccessReviewInstanceMyDecisionsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewAccessReviewInstanceMyDecisionsClientWithBaseURI(baseURI string, subscriptionID string) AccessReviewInstanceMyDecisionsClient { + return AccessReviewInstanceMyDecisionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// GetByID get my single access review instance decision. +// Parameters: +// scheduleDefinitionID - the id of the access review schedule definition. +// ID - the id of the access review instance. +// decisionID - the id of the decision record. +func (client AccessReviewInstanceMyDecisionsClient) GetByID(ctx context.Context, scheduleDefinitionID string, ID string, decisionID string) (result AccessReviewDecision, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewInstanceMyDecisionsClient.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, scheduleDefinitionID, ID, decisionID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceMyDecisionsClient", "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.AccessReviewInstanceMyDecisionsClient", "GetByID", resp, "Failure sending request") + return + } + + result, err = client.GetByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceMyDecisionsClient", "GetByID", resp, "Failure responding to request") + return + } + + return +} + +// GetByIDPreparer prepares the GetByID request. +func (client AccessReviewInstanceMyDecisionsClient) GetByIDPreparer(ctx context.Context, scheduleDefinitionID string, ID string, decisionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "decisionId": autorest.Encode("path", decisionID), + "id": autorest.Encode("path", ID), + "scheduleDefinitionId": autorest.Encode("path", scheduleDefinitionID), + } + + const APIVersion = "2018-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}", 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 AccessReviewInstanceMyDecisionsClient) GetByIDSender(req *http.Request) (*http.Response, error) { + return client.Send(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 AccessReviewInstanceMyDecisionsClient) GetByIDResponder(resp *http.Response) (result AccessReviewDecision, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get my access review instance decisions. +// Parameters: +// scheduleDefinitionID - the id of the access review schedule definition. +// ID - the id of the access review instance. +func (client AccessReviewInstanceMyDecisionsClient) List(ctx context.Context, scheduleDefinitionID string, ID string) (result AccessReviewDecisionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewInstanceMyDecisionsClient.List") + defer func() { + sc := -1 + if result.ardlr.Response.Response != nil { + sc = result.ardlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, scheduleDefinitionID, ID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceMyDecisionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ardlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceMyDecisionsClient", "List", resp, "Failure sending request") + return + } + + result.ardlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceMyDecisionsClient", "List", resp, "Failure responding to request") + return + } + if result.ardlr.hasNextLink() && result.ardlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client AccessReviewInstanceMyDecisionsClient) ListPreparer(ctx context.Context, scheduleDefinitionID string, ID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "id": autorest.Encode("path", ID), + "scheduleDefinitionId": autorest.Encode("path", scheduleDefinitionID), + } + + const APIVersion = "2018-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions", 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 AccessReviewInstanceMyDecisionsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AccessReviewInstanceMyDecisionsClient) ListResponder(resp *http.Response) (result AccessReviewDecisionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AccessReviewInstanceMyDecisionsClient) listNextResults(ctx context.Context, lastResults AccessReviewDecisionListResult) (result AccessReviewDecisionListResult, err error) { + req, err := lastResults.accessReviewDecisionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceMyDecisionsClient", "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.AccessReviewInstanceMyDecisionsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceMyDecisionsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AccessReviewInstanceMyDecisionsClient) ListComplete(ctx context.Context, scheduleDefinitionID string, ID string) (result AccessReviewDecisionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewInstanceMyDecisionsClient.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, scheduleDefinitionID, ID) + return +} + +// Patch record a decision. +// Parameters: +// scheduleDefinitionID - the id of the access review schedule definition. +// ID - the id of the access review instance. +// decisionID - the id of the decision record. +// properties - access review decision properties to patch. +func (client AccessReviewInstanceMyDecisionsClient) Patch(ctx context.Context, scheduleDefinitionID string, ID string, decisionID string, properties AccessReviewDecisionProperties) (result AccessReviewDecision, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewInstanceMyDecisionsClient.Patch") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.PatchPreparer(ctx, scheduleDefinitionID, ID, decisionID, properties) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceMyDecisionsClient", "Patch", nil, "Failure preparing request") + return + } + + resp, err := client.PatchSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceMyDecisionsClient", "Patch", resp, "Failure sending request") + return + } + + result, err = client.PatchResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstanceMyDecisionsClient", "Patch", resp, "Failure responding to request") + return + } + + return +} + +// PatchPreparer prepares the Patch request. +func (client AccessReviewInstanceMyDecisionsClient) PatchPreparer(ctx context.Context, scheduleDefinitionID string, ID string, decisionID string, properties AccessReviewDecisionProperties) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "decisionId": autorest.Encode("path", decisionID), + "id": autorest.Encode("path", ID), + "scheduleDefinitionId": autorest.Encode("path", scheduleDefinitionID), + } + + const APIVersion = "2018-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + properties.BasicAccessReviewDecisionTarget = "" + properties.Recommendation = "" + properties.ReviewedDateTime = nil + properties.AccessReviewActorIdentity = nil + properties.ApplyResult = "" + properties.AppliedDateTime = nil + properties.AccessReviewActorIdentity = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}", pathParameters), + autorest.WithJSON(properties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PatchSender sends the Patch request. The method will close the +// http.Response Body if it receives an error. +func (client AccessReviewInstanceMyDecisionsClient) PatchSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// PatchResponder handles the response to the Patch request. The method always +// closes the http.Response Body. +func (client AccessReviewInstanceMyDecisionsClient) PatchResponder(resp *http.Response) (result AccessReviewDecision, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewinstances.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewinstances.go new file mode 100644 index 000000000000..e92623afb892 --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewinstances.go @@ -0,0 +1,237 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AccessReviewInstancesClient is the client for the AccessReviewInstances methods of the Authorization service. +type AccessReviewInstancesClient struct { + BaseClient +} + +// NewAccessReviewInstancesClient creates an instance of the AccessReviewInstancesClient client. +func NewAccessReviewInstancesClient(subscriptionID string) AccessReviewInstancesClient { + return NewAccessReviewInstancesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAccessReviewInstancesClientWithBaseURI creates an instance of the AccessReviewInstancesClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewAccessReviewInstancesClientWithBaseURI(baseURI string, subscriptionID string) AccessReviewInstancesClient { + return AccessReviewInstancesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// GetByID get access review instances +// Parameters: +// scheduleDefinitionID - the id of the access review schedule definition. +// ID - the id of the access review instance. +func (client AccessReviewInstancesClient) GetByID(ctx context.Context, scheduleDefinitionID string, ID string) (result AccessReviewInstance, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewInstancesClient.GetByID") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.AccessReviewInstancesClient", "GetByID", err.Error()) + } + + req, err := client.GetByIDPreparer(ctx, scheduleDefinitionID, ID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstancesClient", "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.AccessReviewInstancesClient", "GetByID", resp, "Failure sending request") + return + } + + result, err = client.GetByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstancesClient", "GetByID", resp, "Failure responding to request") + return + } + + return +} + +// GetByIDPreparer prepares the GetByID request. +func (client AccessReviewInstancesClient) GetByIDPreparer(ctx context.Context, scheduleDefinitionID string, ID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "id": autorest.Encode("path", ID), + "scheduleDefinitionId": autorest.Encode("path", scheduleDefinitionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", 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 AccessReviewInstancesClient) GetByIDSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetByIDResponder handles the response to the GetByID request. The method always +// closes the http.Response Body. +func (client AccessReviewInstancesClient) GetByIDResponder(resp *http.Response) (result AccessReviewInstance, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get access review instances +// Parameters: +// scheduleDefinitionID - the id of the access review schedule definition. +func (client AccessReviewInstancesClient) List(ctx context.Context, scheduleDefinitionID string) (result AccessReviewInstanceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewInstancesClient.List") + defer func() { + sc := -1 + if result.arilr.Response.Response != nil { + sc = result.arilr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.AccessReviewInstancesClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, scheduleDefinitionID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstancesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.arilr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstancesClient", "List", resp, "Failure sending request") + return + } + + result.arilr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstancesClient", "List", resp, "Failure responding to request") + return + } + if result.arilr.hasNextLink() && result.arilr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client AccessReviewInstancesClient) ListPreparer(ctx context.Context, scheduleDefinitionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scheduleDefinitionId": autorest.Encode("path", scheduleDefinitionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances", 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 AccessReviewInstancesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AccessReviewInstancesClient) ListResponder(resp *http.Response) (result AccessReviewInstanceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AccessReviewInstancesClient) listNextResults(ctx context.Context, lastResults AccessReviewInstanceListResult) (result AccessReviewInstanceListResult, err error) { + req, err := lastResults.accessReviewInstanceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.AccessReviewInstancesClient", "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.AccessReviewInstancesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstancesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AccessReviewInstancesClient) ListComplete(ctx context.Context, scheduleDefinitionID string) (result AccessReviewInstanceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewInstancesClient.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, scheduleDefinitionID) + return +} diff --git a/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewinstancesassignedformyapproval.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewinstancesassignedformyapproval.go new file mode 100644 index 000000000000..5ef3522268ed --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewinstancesassignedformyapproval.go @@ -0,0 +1,224 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AccessReviewInstancesAssignedForMyApprovalClient is the client for the AccessReviewInstancesAssignedForMyApproval +// methods of the Authorization service. +type AccessReviewInstancesAssignedForMyApprovalClient struct { + BaseClient +} + +// NewAccessReviewInstancesAssignedForMyApprovalClient creates an instance of the +// AccessReviewInstancesAssignedForMyApprovalClient client. +func NewAccessReviewInstancesAssignedForMyApprovalClient(subscriptionID string) AccessReviewInstancesAssignedForMyApprovalClient { + return NewAccessReviewInstancesAssignedForMyApprovalClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAccessReviewInstancesAssignedForMyApprovalClientWithBaseURI creates an instance of the +// AccessReviewInstancesAssignedForMyApprovalClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAccessReviewInstancesAssignedForMyApprovalClientWithBaseURI(baseURI string, subscriptionID string) AccessReviewInstancesAssignedForMyApprovalClient { + return AccessReviewInstancesAssignedForMyApprovalClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// GetByID get single access review instance assigned for my approval. +// Parameters: +// scheduleDefinitionID - the id of the access review schedule definition. +// ID - the id of the access review instance. +func (client AccessReviewInstancesAssignedForMyApprovalClient) GetByID(ctx context.Context, scheduleDefinitionID string, ID string) (result AccessReviewInstance, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewInstancesAssignedForMyApprovalClient.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, scheduleDefinitionID, ID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstancesAssignedForMyApprovalClient", "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.AccessReviewInstancesAssignedForMyApprovalClient", "GetByID", resp, "Failure sending request") + return + } + + result, err = client.GetByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstancesAssignedForMyApprovalClient", "GetByID", resp, "Failure responding to request") + return + } + + return +} + +// GetByIDPreparer prepares the GetByID request. +func (client AccessReviewInstancesAssignedForMyApprovalClient) GetByIDPreparer(ctx context.Context, scheduleDefinitionID string, ID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "id": autorest.Encode("path", ID), + "scheduleDefinitionId": autorest.Encode("path", scheduleDefinitionID), + } + + const APIVersion = "2018-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", 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 AccessReviewInstancesAssignedForMyApprovalClient) GetByIDSender(req *http.Request) (*http.Response, error) { + return client.Send(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 AccessReviewInstancesAssignedForMyApprovalClient) GetByIDResponder(resp *http.Response) (result AccessReviewInstance, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get access review instances assigned for my approval. +// Parameters: +// scheduleDefinitionID - the id of the access review schedule definition. +func (client AccessReviewInstancesAssignedForMyApprovalClient) List(ctx context.Context, scheduleDefinitionID string) (result AccessReviewInstanceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewInstancesAssignedForMyApprovalClient.List") + defer func() { + sc := -1 + if result.arilr.Response.Response != nil { + sc = result.arilr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, scheduleDefinitionID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstancesAssignedForMyApprovalClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.arilr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstancesAssignedForMyApprovalClient", "List", resp, "Failure sending request") + return + } + + result.arilr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstancesAssignedForMyApprovalClient", "List", resp, "Failure responding to request") + return + } + if result.arilr.hasNextLink() && result.arilr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client AccessReviewInstancesAssignedForMyApprovalClient) ListPreparer(ctx context.Context, scheduleDefinitionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scheduleDefinitionId": autorest.Encode("path", scheduleDefinitionID), + } + + const APIVersion = "2018-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances", 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 AccessReviewInstancesAssignedForMyApprovalClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AccessReviewInstancesAssignedForMyApprovalClient) ListResponder(resp *http.Response) (result AccessReviewInstanceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AccessReviewInstancesAssignedForMyApprovalClient) listNextResults(ctx context.Context, lastResults AccessReviewInstanceListResult) (result AccessReviewInstanceListResult, err error) { + req, err := lastResults.accessReviewInstanceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.AccessReviewInstancesAssignedForMyApprovalClient", "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.AccessReviewInstancesAssignedForMyApprovalClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewInstancesAssignedForMyApprovalClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AccessReviewInstancesAssignedForMyApprovalClient) ListComplete(ctx context.Context, scheduleDefinitionID string) (result AccessReviewInstanceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewInstancesAssignedForMyApprovalClient.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, scheduleDefinitionID) + return +} diff --git a/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewscheduledefinitions.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewscheduledefinitions.go new file mode 100644 index 000000000000..e6a9ad89db49 --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewscheduledefinitions.go @@ -0,0 +1,478 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AccessReviewScheduleDefinitionsClient is the client for the AccessReviewScheduleDefinitions methods of the +// Authorization service. +type AccessReviewScheduleDefinitionsClient struct { + BaseClient +} + +// NewAccessReviewScheduleDefinitionsClient creates an instance of the AccessReviewScheduleDefinitionsClient client. +func NewAccessReviewScheduleDefinitionsClient(subscriptionID string) AccessReviewScheduleDefinitionsClient { + return NewAccessReviewScheduleDefinitionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAccessReviewScheduleDefinitionsClientWithBaseURI creates an instance of the AccessReviewScheduleDefinitionsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewAccessReviewScheduleDefinitionsClientWithBaseURI(baseURI string, subscriptionID string) AccessReviewScheduleDefinitionsClient { + return AccessReviewScheduleDefinitionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdateByID create or Update access review schedule definition. +// Parameters: +// scheduleDefinitionID - the id of the access review schedule definition. +// properties - access review schedule definition properties. +func (client AccessReviewScheduleDefinitionsClient) CreateOrUpdateByID(ctx context.Context, scheduleDefinitionID string, properties AccessReviewScheduleDefinitionProperties) (result AccessReviewScheduleDefinition, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewScheduleDefinitionsClient.CreateOrUpdateByID") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.AccessReviewScheduleDefinitionsClient", "CreateOrUpdateByID", err.Error()) + } + + req, err := client.CreateOrUpdateByIDPreparer(ctx, scheduleDefinitionID, properties) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewScheduleDefinitionsClient", "CreateOrUpdateByID", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.AccessReviewScheduleDefinitionsClient", "CreateOrUpdateByID", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewScheduleDefinitionsClient", "CreateOrUpdateByID", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdateByIDPreparer prepares the CreateOrUpdateByID request. +func (client AccessReviewScheduleDefinitionsClient) CreateOrUpdateByIDPreparer(ctx context.Context, scheduleDefinitionID string, properties AccessReviewScheduleDefinitionProperties) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scheduleDefinitionId": autorest.Encode("path", scheduleDefinitionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + properties.Status = "" + properties.AccessReviewActorIdentity = nil + properties.AccessReviewScope = nil + properties.ReviewersType = "" + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", pathParameters), + autorest.WithJSON(properties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateByIDSender sends the CreateOrUpdateByID request. The method will close the +// http.Response Body if it receives an error. +func (client AccessReviewScheduleDefinitionsClient) CreateOrUpdateByIDSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateByIDResponder handles the response to the CreateOrUpdateByID request. The method always +// closes the http.Response Body. +func (client AccessReviewScheduleDefinitionsClient) CreateOrUpdateByIDResponder(resp *http.Response) (result AccessReviewScheduleDefinition, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteByID delete access review schedule definition +// Parameters: +// scheduleDefinitionID - the id of the access review schedule definition. +func (client AccessReviewScheduleDefinitionsClient) DeleteByID(ctx context.Context, scheduleDefinitionID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewScheduleDefinitionsClient.DeleteByID") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.AccessReviewScheduleDefinitionsClient", "DeleteByID", err.Error()) + } + + req, err := client.DeleteByIDPreparer(ctx, scheduleDefinitionID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewScheduleDefinitionsClient", "DeleteByID", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteByIDSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "authorization.AccessReviewScheduleDefinitionsClient", "DeleteByID", resp, "Failure sending request") + return + } + + result, err = client.DeleteByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewScheduleDefinitionsClient", "DeleteByID", resp, "Failure responding to request") + return + } + + return +} + +// DeleteByIDPreparer prepares the DeleteByID request. +func (client AccessReviewScheduleDefinitionsClient) DeleteByIDPreparer(ctx context.Context, scheduleDefinitionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scheduleDefinitionId": autorest.Encode("path", scheduleDefinitionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", 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 AccessReviewScheduleDefinitionsClient) DeleteByIDSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteByIDResponder handles the response to the DeleteByID request. The method always +// closes the http.Response Body. +func (client AccessReviewScheduleDefinitionsClient) DeleteByIDResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GetByID get single access review definition +// Parameters: +// scheduleDefinitionID - the id of the access review schedule definition. +func (client AccessReviewScheduleDefinitionsClient) GetByID(ctx context.Context, scheduleDefinitionID string) (result AccessReviewScheduleDefinition, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewScheduleDefinitionsClient.GetByID") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.AccessReviewScheduleDefinitionsClient", "GetByID", err.Error()) + } + + req, err := client.GetByIDPreparer(ctx, scheduleDefinitionID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewScheduleDefinitionsClient", "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.AccessReviewScheduleDefinitionsClient", "GetByID", resp, "Failure sending request") + return + } + + result, err = client.GetByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewScheduleDefinitionsClient", "GetByID", resp, "Failure responding to request") + return + } + + return +} + +// GetByIDPreparer prepares the GetByID request. +func (client AccessReviewScheduleDefinitionsClient) GetByIDPreparer(ctx context.Context, scheduleDefinitionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scheduleDefinitionId": autorest.Encode("path", scheduleDefinitionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", 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 AccessReviewScheduleDefinitionsClient) GetByIDSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetByIDResponder handles the response to the GetByID request. The method always +// closes the http.Response Body. +func (client AccessReviewScheduleDefinitionsClient) GetByIDResponder(resp *http.Response) (result AccessReviewScheduleDefinition, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get access review schedule definitions +func (client AccessReviewScheduleDefinitionsClient) List(ctx context.Context) (result AccessReviewScheduleDefinitionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewScheduleDefinitionsClient.List") + defer func() { + sc := -1 + if result.arsdlr.Response.Response != nil { + sc = result.arsdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.AccessReviewScheduleDefinitionsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewScheduleDefinitionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.arsdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.AccessReviewScheduleDefinitionsClient", "List", resp, "Failure sending request") + return + } + + result.arsdlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewScheduleDefinitionsClient", "List", resp, "Failure responding to request") + return + } + if result.arsdlr.hasNextLink() && result.arsdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client AccessReviewScheduleDefinitionsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions", 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 AccessReviewScheduleDefinitionsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AccessReviewScheduleDefinitionsClient) ListResponder(resp *http.Response) (result AccessReviewScheduleDefinitionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AccessReviewScheduleDefinitionsClient) listNextResults(ctx context.Context, lastResults AccessReviewScheduleDefinitionListResult) (result AccessReviewScheduleDefinitionListResult, err error) { + req, err := lastResults.accessReviewScheduleDefinitionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.AccessReviewScheduleDefinitionsClient", "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.AccessReviewScheduleDefinitionsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewScheduleDefinitionsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AccessReviewScheduleDefinitionsClient) ListComplete(ctx context.Context) (result AccessReviewScheduleDefinitionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewScheduleDefinitionsClient.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 +} + +// Stop stop access review definition +// Parameters: +// scheduleDefinitionID - the id of the access review schedule definition. +func (client AccessReviewScheduleDefinitionsClient) Stop(ctx context.Context, scheduleDefinitionID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewScheduleDefinitionsClient.Stop") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.AccessReviewScheduleDefinitionsClient", "Stop", err.Error()) + } + + req, err := client.StopPreparer(ctx, scheduleDefinitionID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewScheduleDefinitionsClient", "Stop", nil, "Failure preparing request") + return + } + + resp, err := client.StopSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "authorization.AccessReviewScheduleDefinitionsClient", "Stop", resp, "Failure sending request") + return + } + + result, err = client.StopResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewScheduleDefinitionsClient", "Stop", resp, "Failure responding to request") + return + } + + return +} + +// StopPreparer prepares the Stop request. +func (client AccessReviewScheduleDefinitionsClient) StopPreparer(ctx context.Context, scheduleDefinitionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scheduleDefinitionId": autorest.Encode("path", scheduleDefinitionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StopSender sends the Stop request. The method will close the +// http.Response Body if it receives an error. +func (client AccessReviewScheduleDefinitionsClient) StopSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// StopResponder handles the response to the Stop request. The method always +// closes the http.Response Body. +func (client AccessReviewScheduleDefinitionsClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewscheduledefinitionsassignedformyapproval.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewscheduledefinitionsassignedformyapproval.go new file mode 100644 index 000000000000..00ee473e8606 --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/accessreviewscheduledefinitionsassignedformyapproval.go @@ -0,0 +1,143 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AccessReviewScheduleDefinitionsAssignedForMyApprovalClient is the client for the +// AccessReviewScheduleDefinitionsAssignedForMyApproval methods of the Authorization service. +type AccessReviewScheduleDefinitionsAssignedForMyApprovalClient struct { + BaseClient +} + +// NewAccessReviewScheduleDefinitionsAssignedForMyApprovalClient creates an instance of the +// AccessReviewScheduleDefinitionsAssignedForMyApprovalClient client. +func NewAccessReviewScheduleDefinitionsAssignedForMyApprovalClient(subscriptionID string) AccessReviewScheduleDefinitionsAssignedForMyApprovalClient { + return NewAccessReviewScheduleDefinitionsAssignedForMyApprovalClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAccessReviewScheduleDefinitionsAssignedForMyApprovalClientWithBaseURI creates an instance of the +// AccessReviewScheduleDefinitionsAssignedForMyApprovalClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAccessReviewScheduleDefinitionsAssignedForMyApprovalClientWithBaseURI(baseURI string, subscriptionID string) AccessReviewScheduleDefinitionsAssignedForMyApprovalClient { + return AccessReviewScheduleDefinitionsAssignedForMyApprovalClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List get access review instances assigned for my approval. +func (client AccessReviewScheduleDefinitionsAssignedForMyApprovalClient) List(ctx context.Context) (result AccessReviewScheduleDefinitionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewScheduleDefinitionsAssignedForMyApprovalClient.List") + defer func() { + sc := -1 + if result.arsdlr.Response.Response != nil { + sc = result.arsdlr.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.AccessReviewScheduleDefinitionsAssignedForMyApprovalClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.arsdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.AccessReviewScheduleDefinitionsAssignedForMyApprovalClient", "List", resp, "Failure sending request") + return + } + + result.arsdlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewScheduleDefinitionsAssignedForMyApprovalClient", "List", resp, "Failure responding to request") + return + } + if result.arsdlr.hasNextLink() && result.arsdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client AccessReviewScheduleDefinitionsAssignedForMyApprovalClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2018-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"), + 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 AccessReviewScheduleDefinitionsAssignedForMyApprovalClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AccessReviewScheduleDefinitionsAssignedForMyApprovalClient) ListResponder(resp *http.Response) (result AccessReviewScheduleDefinitionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AccessReviewScheduleDefinitionsAssignedForMyApprovalClient) listNextResults(ctx context.Context, lastResults AccessReviewScheduleDefinitionListResult) (result AccessReviewScheduleDefinitionListResult, err error) { + req, err := lastResults.accessReviewScheduleDefinitionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.AccessReviewScheduleDefinitionsAssignedForMyApprovalClient", "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.AccessReviewScheduleDefinitionsAssignedForMyApprovalClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.AccessReviewScheduleDefinitionsAssignedForMyApprovalClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AccessReviewScheduleDefinitionsAssignedForMyApprovalClient) ListComplete(ctx context.Context) (result AccessReviewScheduleDefinitionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewScheduleDefinitionsAssignedForMyApprovalClient.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/services/preview/authorization/mgmt/2020-10-01-preview/authorization/authorizationapi/interfaces.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/authorizationapi/interfaces.go new file mode 100644 index 000000000000..bec21e9e83f7 --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/authorizationapi/interfaces.go @@ -0,0 +1,260 @@ +package authorizationapi + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2020-10-01-preview/authorization" + "github.com/Azure/go-autorest/autorest" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result authorization.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result authorization.OperationListResultIterator, err error) +} + +var _ OperationsClientAPI = (*authorization.OperationsClient)(nil) + +// AccessReviewScheduleDefinitionsClientAPI contains the set of methods on the AccessReviewScheduleDefinitionsClient type. +type AccessReviewScheduleDefinitionsClientAPI interface { + CreateOrUpdateByID(ctx context.Context, scheduleDefinitionID string, properties authorization.AccessReviewScheduleDefinitionProperties) (result authorization.AccessReviewScheduleDefinition, err error) + DeleteByID(ctx context.Context, scheduleDefinitionID string) (result autorest.Response, err error) + GetByID(ctx context.Context, scheduleDefinitionID string) (result authorization.AccessReviewScheduleDefinition, err error) + List(ctx context.Context) (result authorization.AccessReviewScheduleDefinitionListResultPage, err error) + ListComplete(ctx context.Context) (result authorization.AccessReviewScheduleDefinitionListResultIterator, err error) + Stop(ctx context.Context, scheduleDefinitionID string) (result autorest.Response, err error) +} + +var _ AccessReviewScheduleDefinitionsClientAPI = (*authorization.AccessReviewScheduleDefinitionsClient)(nil) + +// AccessReviewInstancesClientAPI contains the set of methods on the AccessReviewInstancesClient type. +type AccessReviewInstancesClientAPI interface { + GetByID(ctx context.Context, scheduleDefinitionID string, ID string) (result authorization.AccessReviewInstance, err error) + List(ctx context.Context, scheduleDefinitionID string) (result authorization.AccessReviewInstanceListResultPage, err error) + ListComplete(ctx context.Context, scheduleDefinitionID string) (result authorization.AccessReviewInstanceListResultIterator, err error) +} + +var _ AccessReviewInstancesClientAPI = (*authorization.AccessReviewInstancesClient)(nil) + +// AccessReviewInstanceClientAPI contains the set of methods on the AccessReviewInstanceClient type. +type AccessReviewInstanceClientAPI interface { + AcceptRecommendations(ctx context.Context, scheduleDefinitionID string, ID string) (result autorest.Response, err error) + ApplyDecisions(ctx context.Context, scheduleDefinitionID string, ID string) (result autorest.Response, err error) + ResetDecisions(ctx context.Context, scheduleDefinitionID string, ID string) (result autorest.Response, err error) + SendReminders(ctx context.Context, scheduleDefinitionID string, ID string) (result autorest.Response, err error) + Stop(ctx context.Context, scheduleDefinitionID string, ID string) (result autorest.Response, err error) +} + +var _ AccessReviewInstanceClientAPI = (*authorization.AccessReviewInstanceClient)(nil) + +// AccessReviewInstanceDecisionsClientAPI contains the set of methods on the AccessReviewInstanceDecisionsClient type. +type AccessReviewInstanceDecisionsClientAPI interface { + List(ctx context.Context, scheduleDefinitionID string, ID string) (result authorization.AccessReviewDecisionListResultPage, err error) + ListComplete(ctx context.Context, scheduleDefinitionID string, ID string) (result authorization.AccessReviewDecisionListResultIterator, err error) +} + +var _ AccessReviewInstanceDecisionsClientAPI = (*authorization.AccessReviewInstanceDecisionsClient)(nil) + +// AccessReviewDefaultSettingsClientAPI contains the set of methods on the AccessReviewDefaultSettingsClient type. +type AccessReviewDefaultSettingsClientAPI interface { + Get(ctx context.Context) (result authorization.AccessReviewDefaultSettings, err error) + Put(ctx context.Context, properties authorization.AccessReviewScheduleSettings) (result authorization.AccessReviewDefaultSettings, err error) +} + +var _ AccessReviewDefaultSettingsClientAPI = (*authorization.AccessReviewDefaultSettingsClient)(nil) + +// AccessReviewScheduleDefinitionsAssignedForMyApprovalClientAPI contains the set of methods on the AccessReviewScheduleDefinitionsAssignedForMyApprovalClient type. +type AccessReviewScheduleDefinitionsAssignedForMyApprovalClientAPI interface { + List(ctx context.Context) (result authorization.AccessReviewScheduleDefinitionListResultPage, err error) + ListComplete(ctx context.Context) (result authorization.AccessReviewScheduleDefinitionListResultIterator, err error) +} + +var _ AccessReviewScheduleDefinitionsAssignedForMyApprovalClientAPI = (*authorization.AccessReviewScheduleDefinitionsAssignedForMyApprovalClient)(nil) + +// AccessReviewInstancesAssignedForMyApprovalClientAPI contains the set of methods on the AccessReviewInstancesAssignedForMyApprovalClient type. +type AccessReviewInstancesAssignedForMyApprovalClientAPI interface { + GetByID(ctx context.Context, scheduleDefinitionID string, ID string) (result authorization.AccessReviewInstance, err error) + List(ctx context.Context, scheduleDefinitionID string) (result authorization.AccessReviewInstanceListResultPage, err error) + ListComplete(ctx context.Context, scheduleDefinitionID string) (result authorization.AccessReviewInstanceListResultIterator, err error) +} + +var _ AccessReviewInstancesAssignedForMyApprovalClientAPI = (*authorization.AccessReviewInstancesAssignedForMyApprovalClient)(nil) + +// AccessReviewInstanceMyDecisionsClientAPI contains the set of methods on the AccessReviewInstanceMyDecisionsClient type. +type AccessReviewInstanceMyDecisionsClientAPI interface { + GetByID(ctx context.Context, scheduleDefinitionID string, ID string, decisionID string) (result authorization.AccessReviewDecision, err error) + List(ctx context.Context, scheduleDefinitionID string, ID string) (result authorization.AccessReviewDecisionListResultPage, err error) + ListComplete(ctx context.Context, scheduleDefinitionID string, ID string) (result authorization.AccessReviewDecisionListResultIterator, err error) + Patch(ctx context.Context, scheduleDefinitionID string, ID string, decisionID string, properties authorization.AccessReviewDecisionProperties) (result authorization.AccessReviewDecision, err error) +} + +var _ AccessReviewInstanceMyDecisionsClientAPI = (*authorization.AccessReviewInstanceMyDecisionsClient)(nil) + +// DenyAssignmentsClientAPI contains the set of methods on the DenyAssignmentsClient type. +type DenyAssignmentsClientAPI interface { + Get(ctx context.Context, scope string, denyAssignmentID string) (result authorization.DenyAssignment, err error) + GetByID(ctx context.Context, denyAssignmentID string) (result authorization.DenyAssignment, err error) + List(ctx context.Context, filter string) (result authorization.DenyAssignmentListResultPage, err error) + ListComplete(ctx context.Context, filter string) (result authorization.DenyAssignmentListResultIterator, err error) + ListForResource(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (result authorization.DenyAssignmentListResultPage, err error) + ListForResourceComplete(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (result authorization.DenyAssignmentListResultIterator, err error) + ListForResourceGroup(ctx context.Context, resourceGroupName string, filter string) (result authorization.DenyAssignmentListResultPage, err error) + ListForResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string) (result authorization.DenyAssignmentListResultIterator, err error) + ListForScope(ctx context.Context, scope string, filter string) (result authorization.DenyAssignmentListResultPage, err error) + ListForScopeComplete(ctx context.Context, scope string, filter string) (result authorization.DenyAssignmentListResultIterator, err error) +} + +var _ DenyAssignmentsClientAPI = (*authorization.DenyAssignmentsClient)(nil) + +// ProviderOperationsMetadataClientAPI contains the set of methods on the ProviderOperationsMetadataClient type. +type ProviderOperationsMetadataClientAPI interface { + Get(ctx context.Context, resourceProviderNamespace string, expand string) (result authorization.ProviderOperationsMetadata, err error) + List(ctx context.Context, expand string) (result authorization.ProviderOperationsMetadataListResultPage, err error) + ListComplete(ctx context.Context, expand string) (result authorization.ProviderOperationsMetadataListResultIterator, err error) +} + +var _ ProviderOperationsMetadataClientAPI = (*authorization.ProviderOperationsMetadataClient)(nil) + +// RoleAssignmentsClientAPI contains the set of methods on the RoleAssignmentsClient type. +type RoleAssignmentsClientAPI interface { + Create(ctx context.Context, scope string, roleAssignmentName string, parameters authorization.RoleAssignmentCreateParameters) (result authorization.RoleAssignment, err error) + CreateByID(ctx context.Context, roleAssignmentID string, parameters authorization.RoleAssignmentCreateParameters) (result authorization.RoleAssignment, err error) + Delete(ctx context.Context, scope string, roleAssignmentName string, tenantID string) (result authorization.RoleAssignment, err error) + DeleteByID(ctx context.Context, roleAssignmentID string, tenantID string) (result authorization.RoleAssignment, err error) + Get(ctx context.Context, scope string, roleAssignmentName string, tenantID string) (result authorization.RoleAssignment, err error) + GetByID(ctx context.Context, roleAssignmentID string, tenantID string) (result authorization.RoleAssignment, err error) + ListForResource(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, resourceType string, resourceName string, filter string, tenantID string) (result authorization.RoleAssignmentListResultPage, err error) + ListForResourceComplete(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, resourceType string, resourceName string, filter string, tenantID string) (result authorization.RoleAssignmentListResultIterator, err error) + ListForResourceGroup(ctx context.Context, resourceGroupName string, filter string, tenantID string) (result authorization.RoleAssignmentListResultPage, err error) + ListForResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string, tenantID string) (result authorization.RoleAssignmentListResultIterator, err error) + ListForScope(ctx context.Context, scope string, filter string, tenantID string) (result authorization.RoleAssignmentListResultPage, err error) + ListForScopeComplete(ctx context.Context, scope string, filter string, tenantID string) (result authorization.RoleAssignmentListResultIterator, err error) + ListForSubscription(ctx context.Context, filter string, tenantID string) (result authorization.RoleAssignmentListResultPage, err error) + ListForSubscriptionComplete(ctx context.Context, filter string, tenantID string) (result authorization.RoleAssignmentListResultIterator, err error) + Validate(ctx context.Context, scope string, roleAssignmentName string, parameters authorization.RoleAssignmentCreateParameters) (result authorization.ValidationResponse, err error) + ValidateByID(ctx context.Context, roleAssignmentID string, parameters authorization.RoleAssignmentCreateParameters) (result authorization.ValidationResponse, err error) +} + +var _ RoleAssignmentsClientAPI = (*authorization.RoleAssignmentsClient)(nil) + +// PermissionsClientAPI contains the set of methods on the PermissionsClient type. +type PermissionsClientAPI interface { + ListForResource(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result authorization.PermissionGetResultPage, err error) + ListForResourceComplete(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result authorization.PermissionGetResultIterator, err error) + ListForResourceGroup(ctx context.Context, resourceGroupName string) (result authorization.PermissionGetResultPage, err error) + ListForResourceGroupComplete(ctx context.Context, resourceGroupName string) (result authorization.PermissionGetResultIterator, err error) +} + +var _ PermissionsClientAPI = (*authorization.PermissionsClient)(nil) + +// RoleDefinitionsClientAPI contains the set of methods on the RoleDefinitionsClient type. +type RoleDefinitionsClientAPI interface { + CreateOrUpdate(ctx context.Context, scope string, roleDefinitionID string, roleDefinition authorization.RoleDefinition) (result authorization.RoleDefinition, err error) + Delete(ctx context.Context, scope string, roleDefinitionID string) (result authorization.RoleDefinition, err error) + Get(ctx context.Context, scope string, roleDefinitionID string) (result authorization.RoleDefinition, err error) + GetByID(ctx context.Context, roleID string) (result authorization.RoleDefinition, err error) + List(ctx context.Context, scope string, filter string) (result authorization.RoleDefinitionListResultPage, err error) + ListComplete(ctx context.Context, scope string, filter string) (result authorization.RoleDefinitionListResultIterator, err error) +} + +var _ RoleDefinitionsClientAPI = (*authorization.RoleDefinitionsClient)(nil) + +// RoleAssignmentMetricsClientAPI contains the set of methods on the RoleAssignmentMetricsClient type. +type RoleAssignmentMetricsClientAPI interface { + GetMetricsForSubscription(ctx context.Context) (result authorization.RoleAssignmentMetricsResult, err error) +} + +var _ RoleAssignmentMetricsClientAPI = (*authorization.RoleAssignmentMetricsClient)(nil) + +// EligibleChildResourcesClientAPI contains the set of methods on the EligibleChildResourcesClient type. +type EligibleChildResourcesClientAPI interface { + Get(ctx context.Context, scope string, filter string) (result authorization.EligibleChildResourcesListResultPage, err error) + GetComplete(ctx context.Context, scope string, filter string) (result authorization.EligibleChildResourcesListResultIterator, err error) +} + +var _ EligibleChildResourcesClientAPI = (*authorization.EligibleChildResourcesClient)(nil) + +// RoleAssignmentSchedulesClientAPI contains the set of methods on the RoleAssignmentSchedulesClient type. +type RoleAssignmentSchedulesClientAPI interface { + Get(ctx context.Context, scope string, roleAssignmentScheduleName string) (result authorization.RoleAssignmentSchedule, err error) + ListForScope(ctx context.Context, scope string, filter string) (result authorization.RoleAssignmentScheduleListResultPage, err error) + ListForScopeComplete(ctx context.Context, scope string, filter string) (result authorization.RoleAssignmentScheduleListResultIterator, err error) +} + +var _ RoleAssignmentSchedulesClientAPI = (*authorization.RoleAssignmentSchedulesClient)(nil) + +// RoleAssignmentScheduleInstancesClientAPI contains the set of methods on the RoleAssignmentScheduleInstancesClient type. +type RoleAssignmentScheduleInstancesClientAPI interface { + Get(ctx context.Context, scope string, roleAssignmentScheduleInstanceName string) (result authorization.RoleAssignmentScheduleInstance, err error) + ListForScope(ctx context.Context, scope string, filter string) (result authorization.RoleAssignmentScheduleInstanceListResultPage, err error) + ListForScopeComplete(ctx context.Context, scope string, filter string) (result authorization.RoleAssignmentScheduleInstanceListResultIterator, err error) +} + +var _ RoleAssignmentScheduleInstancesClientAPI = (*authorization.RoleAssignmentScheduleInstancesClient)(nil) + +// RoleAssignmentScheduleRequestsClientAPI contains the set of methods on the RoleAssignmentScheduleRequestsClient type. +type RoleAssignmentScheduleRequestsClientAPI interface { + Cancel(ctx context.Context, scope string, roleAssignmentScheduleRequestName string) (result autorest.Response, err error) + Create(ctx context.Context, scope string, roleAssignmentScheduleRequestName string, parameters authorization.RoleAssignmentScheduleRequest) (result authorization.RoleAssignmentScheduleRequest, err error) + Get(ctx context.Context, scope string, roleAssignmentScheduleRequestName string) (result authorization.RoleAssignmentScheduleRequest, err error) + ListForScope(ctx context.Context, scope string, filter string) (result authorization.RoleAssignmentScheduleRequestListResultPage, err error) + ListForScopeComplete(ctx context.Context, scope string, filter string) (result authorization.RoleAssignmentScheduleRequestListResultIterator, err error) +} + +var _ RoleAssignmentScheduleRequestsClientAPI = (*authorization.RoleAssignmentScheduleRequestsClient)(nil) + +// RoleEligibilitySchedulesClientAPI contains the set of methods on the RoleEligibilitySchedulesClient type. +type RoleEligibilitySchedulesClientAPI interface { + Get(ctx context.Context, scope string, roleEligibilityScheduleName string) (result authorization.RoleEligibilitySchedule, err error) + ListForScope(ctx context.Context, scope string, filter string) (result authorization.RoleEligibilityScheduleListResultPage, err error) + ListForScopeComplete(ctx context.Context, scope string, filter string) (result authorization.RoleEligibilityScheduleListResultIterator, err error) +} + +var _ RoleEligibilitySchedulesClientAPI = (*authorization.RoleEligibilitySchedulesClient)(nil) + +// RoleEligibilityScheduleInstancesClientAPI contains the set of methods on the RoleEligibilityScheduleInstancesClient type. +type RoleEligibilityScheduleInstancesClientAPI interface { + Get(ctx context.Context, scope string, roleEligibilityScheduleInstanceName string) (result authorization.RoleEligibilityScheduleInstance, err error) + ListForScope(ctx context.Context, scope string, filter string) (result authorization.RoleEligibilityScheduleInstanceListResultPage, err error) + ListForScopeComplete(ctx context.Context, scope string, filter string) (result authorization.RoleEligibilityScheduleInstanceListResultIterator, err error) +} + +var _ RoleEligibilityScheduleInstancesClientAPI = (*authorization.RoleEligibilityScheduleInstancesClient)(nil) + +// RoleEligibilityScheduleRequestsClientAPI contains the set of methods on the RoleEligibilityScheduleRequestsClient type. +type RoleEligibilityScheduleRequestsClientAPI interface { + Cancel(ctx context.Context, scope string, roleEligibilityScheduleRequestName string) (result autorest.Response, err error) + Create(ctx context.Context, scope string, roleEligibilityScheduleRequestName string, parameters authorization.RoleEligibilityScheduleRequest) (result authorization.RoleEligibilityScheduleRequest, err error) + Get(ctx context.Context, scope string, roleEligibilityScheduleRequestName string) (result authorization.RoleEligibilityScheduleRequest, err error) + ListForScope(ctx context.Context, scope string, filter string) (result authorization.RoleEligibilityScheduleRequestListResultPage, err error) + ListForScopeComplete(ctx context.Context, scope string, filter string) (result authorization.RoleEligibilityScheduleRequestListResultIterator, err error) +} + +var _ RoleEligibilityScheduleRequestsClientAPI = (*authorization.RoleEligibilityScheduleRequestsClient)(nil) + +// RoleManagementPoliciesClientAPI contains the set of methods on the RoleManagementPoliciesClient type. +type RoleManagementPoliciesClientAPI interface { + Delete(ctx context.Context, scope string, roleManagementPolicyName string) (result autorest.Response, err error) + Get(ctx context.Context, scope string, roleManagementPolicyName string) (result authorization.RoleManagementPolicy, err error) + ListForScope(ctx context.Context, scope string) (result authorization.RoleManagementPolicyListResultPage, err error) + ListForScopeComplete(ctx context.Context, scope string) (result authorization.RoleManagementPolicyListResultIterator, err error) + Update(ctx context.Context, scope string, roleManagementPolicyName string, parameters authorization.RoleManagementPolicy) (result authorization.RoleManagementPolicy, err error) +} + +var _ RoleManagementPoliciesClientAPI = (*authorization.RoleManagementPoliciesClient)(nil) + +// RoleManagementPolicyAssignmentsClientAPI contains the set of methods on the RoleManagementPolicyAssignmentsClient type. +type RoleManagementPolicyAssignmentsClientAPI interface { + Create(ctx context.Context, scope string, roleManagementPolicyAssignmentName string, parameters authorization.RoleManagementPolicyAssignment) (result authorization.RoleManagementPolicyAssignment, err error) + Delete(ctx context.Context, scope string, roleManagementPolicyAssignmentName string) (result autorest.Response, err error) + Get(ctx context.Context, scope string, roleManagementPolicyAssignmentName string) (result authorization.RoleManagementPolicyAssignment, err error) + ListForScope(ctx context.Context, scope string) (result authorization.RoleManagementPolicyAssignmentListResultPage, err error) + ListForScopeComplete(ctx context.Context, scope string) (result authorization.RoleManagementPolicyAssignmentListResultIterator, err error) +} + +var _ RoleManagementPolicyAssignmentsClientAPI = (*authorization.RoleManagementPolicyAssignmentsClient)(nil) diff --git a/services/preview/authorization/mgmt/2020-10-01-preview/authorization/client.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/client.go new file mode 100644 index 000000000000..8accd9738c11 --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/client.go @@ -0,0 +1,41 @@ +// Package authorization implements the Azure ARM Authorization service API version . +// +// +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service 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 using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/authorization/mgmt/2020-10-01-preview/authorization/denyassignments.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/denyassignments.go new file mode 100644 index 000000000000..a98e1d59fbc9 --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/denyassignments.go @@ -0,0 +1,724 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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 using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +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 + } + + 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 client.Send(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, + 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 + } + + 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 client.Send(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, + 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) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.DenyAssignmentsClient", "List", err.Error()) + } + + 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 + } + if result.dalr.hasNextLink() && result.dalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 client.Send(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, + 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. The name is case insensitive. +// 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) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.DenyAssignmentsClient", "ListForResource", err.Error()) + } + + 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 + } + if result.dalr.hasNextLink() && result.dalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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": 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 client.Send(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, + 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. The name is case insensitive. +// 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) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.DenyAssignmentsClient", "ListForResourceGroup", err.Error()) + } + + 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 + } + if result.dalr.hasNextLink() && result.dalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 client.Send(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, + 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 + } + if result.dalr.hasNextLink() && result.dalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 client.Send(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, + 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/services/preview/authorization/mgmt/2020-10-01-preview/authorization/eligiblechildresources.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/eligiblechildresources.go new file mode 100644 index 000000000000..4147bf99da2f --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/eligiblechildresources.go @@ -0,0 +1,154 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// EligibleChildResourcesClient is the client for the EligibleChildResources methods of the Authorization service. +type EligibleChildResourcesClient struct { + BaseClient +} + +// NewEligibleChildResourcesClient creates an instance of the EligibleChildResourcesClient client. +func NewEligibleChildResourcesClient(subscriptionID string) EligibleChildResourcesClient { + return NewEligibleChildResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewEligibleChildResourcesClientWithBaseURI creates an instance of the EligibleChildResourcesClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewEligibleChildResourcesClientWithBaseURI(baseURI string, subscriptionID string) EligibleChildResourcesClient { + return EligibleChildResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the child resources of a resource on which user has eligible access +// Parameters: +// scope - the scope of the role management policy. +// filter - the filter to apply on the operation. Use $filter=resourceType+eq+'Subscription' to filter on only +// resource of type = 'Subscription'. Use +// $filter=resourceType+eq+'subscription'+or+resourceType+eq+'resourcegroup' to filter on resource of type = +// 'Subscription' or 'ResourceGroup' +func (client EligibleChildResourcesClient) Get(ctx context.Context, scope string, filter string) (result EligibleChildResourcesListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EligibleChildResourcesClient.Get") + defer func() { + sc := -1 + if result.ecrlr.Response.Response != nil { + sc = result.ecrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.getNextResults + req, err := client.GetPreparer(ctx, scope, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.EligibleChildResourcesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.ecrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.EligibleChildResourcesClient", "Get", resp, "Failure sending request") + return + } + + result.ecrlr, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.EligibleChildResourcesClient", "Get", resp, "Failure responding to request") + return + } + if result.ecrlr.hasNextLink() && result.ecrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client EligibleChildResourcesClient) GetPreparer(ctx context.Context, scope string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2020-10-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/eligibleChildResources", 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 EligibleChildResourcesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(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 EligibleChildResourcesClient) GetResponder(resp *http.Response) (result EligibleChildResourcesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// getNextResults retrieves the next set of results, if any. +func (client EligibleChildResourcesClient) getNextResults(ctx context.Context, lastResults EligibleChildResourcesListResult) (result EligibleChildResourcesListResult, err error) { + req, err := lastResults.eligibleChildResourcesListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.EligibleChildResourcesClient", "getNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "authorization.EligibleChildResourcesClient", "getNextResults", resp, "Failure sending next results request") + } + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.EligibleChildResourcesClient", "getNextResults", resp, "Failure responding to next results request") + } + return +} + +// GetComplete enumerates all values, automatically crossing page boundaries as required. +func (client EligibleChildResourcesClient) GetComplete(ctx context.Context, scope string, filter string) (result EligibleChildResourcesListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EligibleChildResourcesClient.Get") + 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.Get(ctx, scope, filter) + return +} diff --git a/services/preview/authorization/mgmt/2020-10-01-preview/authorization/enums.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/enums.go new file mode 100644 index 000000000000..6e5fdf8c248f --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/enums.go @@ -0,0 +1,559 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// AccessRecommendationType enumerates the values for access recommendation type. +type AccessRecommendationType string + +const ( + // Approve ... + Approve AccessRecommendationType = "Approve" + // Deny ... + Deny AccessRecommendationType = "Deny" + // NoInfoAvailable ... + NoInfoAvailable AccessRecommendationType = "NoInfoAvailable" +) + +// PossibleAccessRecommendationTypeValues returns an array of possible values for the AccessRecommendationType const type. +func PossibleAccessRecommendationTypeValues() []AccessRecommendationType { + return []AccessRecommendationType{Approve, Deny, NoInfoAvailable} +} + +// AccessReviewActorIdentityType enumerates the values for access review actor identity type. +type AccessReviewActorIdentityType string + +const ( + // ServicePrincipal ... + ServicePrincipal AccessReviewActorIdentityType = "servicePrincipal" + // User ... + User AccessReviewActorIdentityType = "user" +) + +// PossibleAccessReviewActorIdentityTypeValues returns an array of possible values for the AccessReviewActorIdentityType const type. +func PossibleAccessReviewActorIdentityTypeValues() []AccessReviewActorIdentityType { + return []AccessReviewActorIdentityType{ServicePrincipal, User} +} + +// AccessReviewApplyResult enumerates the values for access review apply result. +type AccessReviewApplyResult string + +const ( + // AccessReviewApplyResultAppliedSuccessfully ... + AccessReviewApplyResultAppliedSuccessfully AccessReviewApplyResult = "AppliedSuccessfully" + // AccessReviewApplyResultAppliedSuccessfullyButObjectNotFound ... + AccessReviewApplyResultAppliedSuccessfullyButObjectNotFound AccessReviewApplyResult = "AppliedSuccessfullyButObjectNotFound" + // AccessReviewApplyResultAppliedWithUnknownFailure ... + AccessReviewApplyResultAppliedWithUnknownFailure AccessReviewApplyResult = "AppliedWithUnknownFailure" + // AccessReviewApplyResultApplying ... + AccessReviewApplyResultApplying AccessReviewApplyResult = "Applying" + // AccessReviewApplyResultApplyNotSupported ... + AccessReviewApplyResultApplyNotSupported AccessReviewApplyResult = "ApplyNotSupported" + // AccessReviewApplyResultNew ... + AccessReviewApplyResultNew AccessReviewApplyResult = "New" +) + +// PossibleAccessReviewApplyResultValues returns an array of possible values for the AccessReviewApplyResult const type. +func PossibleAccessReviewApplyResultValues() []AccessReviewApplyResult { + return []AccessReviewApplyResult{AccessReviewApplyResultAppliedSuccessfully, AccessReviewApplyResultAppliedSuccessfullyButObjectNotFound, AccessReviewApplyResultAppliedWithUnknownFailure, AccessReviewApplyResultApplying, AccessReviewApplyResultApplyNotSupported, AccessReviewApplyResultNew} +} + +// AccessReviewInstanceStatus enumerates the values for access review instance status. +type AccessReviewInstanceStatus string + +const ( + // Applied ... + Applied AccessReviewInstanceStatus = "Applied" + // Applying ... + Applying AccessReviewInstanceStatus = "Applying" + // AutoReviewed ... + AutoReviewed AccessReviewInstanceStatus = "AutoReviewed" + // AutoReviewing ... + AutoReviewing AccessReviewInstanceStatus = "AutoReviewing" + // Completed ... + Completed AccessReviewInstanceStatus = "Completed" + // Completing ... + Completing AccessReviewInstanceStatus = "Completing" + // Initializing ... + Initializing AccessReviewInstanceStatus = "Initializing" + // InProgress ... + InProgress AccessReviewInstanceStatus = "InProgress" + // NotStarted ... + NotStarted AccessReviewInstanceStatus = "NotStarted" + // Scheduled ... + Scheduled AccessReviewInstanceStatus = "Scheduled" + // Starting ... + Starting AccessReviewInstanceStatus = "Starting" +) + +// PossibleAccessReviewInstanceStatusValues returns an array of possible values for the AccessReviewInstanceStatus const type. +func PossibleAccessReviewInstanceStatusValues() []AccessReviewInstanceStatus { + return []AccessReviewInstanceStatus{Applied, Applying, AutoReviewed, AutoReviewing, Completed, Completing, Initializing, InProgress, NotStarted, Scheduled, Starting} +} + +// AccessReviewRecurrencePatternType enumerates the values for access review recurrence pattern type. +type AccessReviewRecurrencePatternType string + +const ( + // AbsoluteMonthly ... + AbsoluteMonthly AccessReviewRecurrencePatternType = "absoluteMonthly" + // Weekly ... + Weekly AccessReviewRecurrencePatternType = "weekly" +) + +// PossibleAccessReviewRecurrencePatternTypeValues returns an array of possible values for the AccessReviewRecurrencePatternType const type. +func PossibleAccessReviewRecurrencePatternTypeValues() []AccessReviewRecurrencePatternType { + return []AccessReviewRecurrencePatternType{AbsoluteMonthly, Weekly} +} + +// AccessReviewRecurrenceRangeType enumerates the values for access review recurrence range type. +type AccessReviewRecurrenceRangeType string + +const ( + // EndDate ... + EndDate AccessReviewRecurrenceRangeType = "endDate" + // NoEnd ... + NoEnd AccessReviewRecurrenceRangeType = "noEnd" + // Numbered ... + Numbered AccessReviewRecurrenceRangeType = "numbered" +) + +// PossibleAccessReviewRecurrenceRangeTypeValues returns an array of possible values for the AccessReviewRecurrenceRangeType const type. +func PossibleAccessReviewRecurrenceRangeTypeValues() []AccessReviewRecurrenceRangeType { + return []AccessReviewRecurrenceRangeType{EndDate, NoEnd, Numbered} +} + +// AccessReviewResult enumerates the values for access review result. +type AccessReviewResult string + +const ( + // AccessReviewResultApprove ... + AccessReviewResultApprove AccessReviewResult = "Approve" + // AccessReviewResultDeny ... + AccessReviewResultDeny AccessReviewResult = "Deny" + // AccessReviewResultDontKnow ... + AccessReviewResultDontKnow AccessReviewResult = "DontKnow" + // AccessReviewResultNotNotified ... + AccessReviewResultNotNotified AccessReviewResult = "NotNotified" + // AccessReviewResultNotReviewed ... + AccessReviewResultNotReviewed AccessReviewResult = "NotReviewed" +) + +// PossibleAccessReviewResultValues returns an array of possible values for the AccessReviewResult const type. +func PossibleAccessReviewResultValues() []AccessReviewResult { + return []AccessReviewResult{AccessReviewResultApprove, AccessReviewResultDeny, AccessReviewResultDontKnow, AccessReviewResultNotNotified, AccessReviewResultNotReviewed} +} + +// AccessReviewReviewerType enumerates the values for access review reviewer type. +type AccessReviewReviewerType string + +const ( + // AccessReviewReviewerTypeServicePrincipal ... + AccessReviewReviewerTypeServicePrincipal AccessReviewReviewerType = "servicePrincipal" + // AccessReviewReviewerTypeUser ... + AccessReviewReviewerTypeUser AccessReviewReviewerType = "user" +) + +// PossibleAccessReviewReviewerTypeValues returns an array of possible values for the AccessReviewReviewerType const type. +func PossibleAccessReviewReviewerTypeValues() []AccessReviewReviewerType { + return []AccessReviewReviewerType{AccessReviewReviewerTypeServicePrincipal, AccessReviewReviewerTypeUser} +} + +// AccessReviewScheduleDefinitionReviewersType enumerates the values for access review schedule definition +// reviewers type. +type AccessReviewScheduleDefinitionReviewersType string + +const ( + // Assigned ... + Assigned AccessReviewScheduleDefinitionReviewersType = "Assigned" + // Managers ... + Managers AccessReviewScheduleDefinitionReviewersType = "Managers" + // Self ... + Self AccessReviewScheduleDefinitionReviewersType = "Self" +) + +// PossibleAccessReviewScheduleDefinitionReviewersTypeValues returns an array of possible values for the AccessReviewScheduleDefinitionReviewersType const type. +func PossibleAccessReviewScheduleDefinitionReviewersTypeValues() []AccessReviewScheduleDefinitionReviewersType { + return []AccessReviewScheduleDefinitionReviewersType{Assigned, Managers, Self} +} + +// AccessReviewScheduleDefinitionStatus enumerates the values for access review schedule definition status. +type AccessReviewScheduleDefinitionStatus string + +const ( + // AccessReviewScheduleDefinitionStatusApplied ... + AccessReviewScheduleDefinitionStatusApplied AccessReviewScheduleDefinitionStatus = "Applied" + // AccessReviewScheduleDefinitionStatusApplying ... + AccessReviewScheduleDefinitionStatusApplying AccessReviewScheduleDefinitionStatus = "Applying" + // AccessReviewScheduleDefinitionStatusAutoReviewed ... + AccessReviewScheduleDefinitionStatusAutoReviewed AccessReviewScheduleDefinitionStatus = "AutoReviewed" + // AccessReviewScheduleDefinitionStatusAutoReviewing ... + AccessReviewScheduleDefinitionStatusAutoReviewing AccessReviewScheduleDefinitionStatus = "AutoReviewing" + // AccessReviewScheduleDefinitionStatusCompleted ... + AccessReviewScheduleDefinitionStatusCompleted AccessReviewScheduleDefinitionStatus = "Completed" + // AccessReviewScheduleDefinitionStatusCompleting ... + AccessReviewScheduleDefinitionStatusCompleting AccessReviewScheduleDefinitionStatus = "Completing" + // AccessReviewScheduleDefinitionStatusInitializing ... + AccessReviewScheduleDefinitionStatusInitializing AccessReviewScheduleDefinitionStatus = "Initializing" + // AccessReviewScheduleDefinitionStatusInProgress ... + AccessReviewScheduleDefinitionStatusInProgress AccessReviewScheduleDefinitionStatus = "InProgress" + // AccessReviewScheduleDefinitionStatusNotStarted ... + AccessReviewScheduleDefinitionStatusNotStarted AccessReviewScheduleDefinitionStatus = "NotStarted" + // AccessReviewScheduleDefinitionStatusScheduled ... + AccessReviewScheduleDefinitionStatusScheduled AccessReviewScheduleDefinitionStatus = "Scheduled" + // AccessReviewScheduleDefinitionStatusStarting ... + AccessReviewScheduleDefinitionStatusStarting AccessReviewScheduleDefinitionStatus = "Starting" +) + +// PossibleAccessReviewScheduleDefinitionStatusValues returns an array of possible values for the AccessReviewScheduleDefinitionStatus const type. +func PossibleAccessReviewScheduleDefinitionStatusValues() []AccessReviewScheduleDefinitionStatus { + return []AccessReviewScheduleDefinitionStatus{AccessReviewScheduleDefinitionStatusApplied, AccessReviewScheduleDefinitionStatusApplying, AccessReviewScheduleDefinitionStatusAutoReviewed, AccessReviewScheduleDefinitionStatusAutoReviewing, AccessReviewScheduleDefinitionStatusCompleted, AccessReviewScheduleDefinitionStatusCompleting, AccessReviewScheduleDefinitionStatusInitializing, AccessReviewScheduleDefinitionStatusInProgress, AccessReviewScheduleDefinitionStatusNotStarted, AccessReviewScheduleDefinitionStatusScheduled, AccessReviewScheduleDefinitionStatusStarting} +} + +// AccessReviewScopePrincipalType enumerates the values for access review scope principal type. +type AccessReviewScopePrincipalType string + +const ( + // AccessReviewScopePrincipalTypeServicePrincipal ... + AccessReviewScopePrincipalTypeServicePrincipal AccessReviewScopePrincipalType = "servicePrincipal" + // AccessReviewScopePrincipalTypeUser ... + AccessReviewScopePrincipalTypeUser AccessReviewScopePrincipalType = "user" +) + +// PossibleAccessReviewScopePrincipalTypeValues returns an array of possible values for the AccessReviewScopePrincipalType const type. +func PossibleAccessReviewScopePrincipalTypeValues() []AccessReviewScopePrincipalType { + return []AccessReviewScopePrincipalType{AccessReviewScopePrincipalTypeServicePrincipal, AccessReviewScopePrincipalTypeUser} +} + +// ApprovalMode enumerates the values for approval mode. +type ApprovalMode string + +const ( + // NoApproval ... + NoApproval ApprovalMode = "NoApproval" + // Parallel ... + Parallel ApprovalMode = "Parallel" + // Serial ... + Serial ApprovalMode = "Serial" + // SingleStage ... + SingleStage ApprovalMode = "SingleStage" +) + +// PossibleApprovalModeValues returns an array of possible values for the ApprovalMode const type. +func PossibleApprovalModeValues() []ApprovalMode { + return []ApprovalMode{NoApproval, Parallel, Serial, SingleStage} +} + +// AssignmentType enumerates the values for assignment type. +type AssignmentType string + +const ( + // AssignmentTypeActivated ... + AssignmentTypeActivated AssignmentType = "Activated" + // AssignmentTypeAssigned ... + AssignmentTypeAssigned AssignmentType = "Assigned" +) + +// PossibleAssignmentTypeValues returns an array of possible values for the AssignmentType const type. +func PossibleAssignmentTypeValues() []AssignmentType { + return []AssignmentType{AssignmentTypeActivated, AssignmentTypeAssigned} +} + +// DefaultDecisionType enumerates the values for default decision type. +type DefaultDecisionType string + +const ( + // DefaultDecisionTypeApprove ... + DefaultDecisionTypeApprove DefaultDecisionType = "Approve" + // DefaultDecisionTypeDeny ... + DefaultDecisionTypeDeny DefaultDecisionType = "Deny" + // DefaultDecisionTypeRecommendation ... + DefaultDecisionTypeRecommendation DefaultDecisionType = "Recommendation" +) + +// PossibleDefaultDecisionTypeValues returns an array of possible values for the DefaultDecisionType const type. +func PossibleDefaultDecisionTypeValues() []DefaultDecisionType { + return []DefaultDecisionType{DefaultDecisionTypeApprove, DefaultDecisionTypeDeny, DefaultDecisionTypeRecommendation} +} + +// EnablementRules enumerates the values for enablement rules. +type EnablementRules string + +const ( + // Justification ... + Justification EnablementRules = "Justification" + // MultiFactorAuthentication ... + MultiFactorAuthentication EnablementRules = "MultiFactorAuthentication" + // Ticketing ... + Ticketing EnablementRules = "Ticketing" +) + +// PossibleEnablementRulesValues returns an array of possible values for the EnablementRules const type. +func PossibleEnablementRulesValues() []EnablementRules { + return []EnablementRules{Justification, MultiFactorAuthentication, Ticketing} +} + +// MemberType enumerates the values for member type. +type MemberType string + +const ( + // Direct ... + Direct MemberType = "Direct" + // Group ... + Group MemberType = "Group" + // Inherited ... + Inherited MemberType = "Inherited" +) + +// PossibleMemberTypeValues returns an array of possible values for the MemberType const type. +func PossibleMemberTypeValues() []MemberType { + return []MemberType{Direct, Group, Inherited} +} + +// NotificationDeliveryMechanism enumerates the values for notification delivery mechanism. +type NotificationDeliveryMechanism string + +const ( + // Email ... + Email NotificationDeliveryMechanism = "Email" +) + +// PossibleNotificationDeliveryMechanismValues returns an array of possible values for the NotificationDeliveryMechanism const type. +func PossibleNotificationDeliveryMechanismValues() []NotificationDeliveryMechanism { + return []NotificationDeliveryMechanism{Email} +} + +// NotificationLevel enumerates the values for notification level. +type NotificationLevel string + +const ( + // All ... + All NotificationLevel = "All" + // Critical ... + Critical NotificationLevel = "Critical" + // None ... + None NotificationLevel = "None" +) + +// PossibleNotificationLevelValues returns an array of possible values for the NotificationLevel const type. +func PossibleNotificationLevelValues() []NotificationLevel { + return []NotificationLevel{All, Critical, None} +} + +// PrincipalType enumerates the values for principal type. +type PrincipalType string + +const ( + // PrincipalTypeDevice ... + PrincipalTypeDevice PrincipalType = "Device" + // PrincipalTypeForeignGroup ... + PrincipalTypeForeignGroup PrincipalType = "ForeignGroup" + // PrincipalTypeGroup ... + PrincipalTypeGroup PrincipalType = "Group" + // PrincipalTypeServicePrincipal ... + PrincipalTypeServicePrincipal PrincipalType = "ServicePrincipal" + // PrincipalTypeUser ... + PrincipalTypeUser PrincipalType = "User" +) + +// PossiblePrincipalTypeValues returns an array of possible values for the PrincipalType const type. +func PossiblePrincipalTypeValues() []PrincipalType { + return []PrincipalType{PrincipalTypeDevice, PrincipalTypeForeignGroup, PrincipalTypeGroup, PrincipalTypeServicePrincipal, PrincipalTypeUser} +} + +// RecipientType enumerates the values for recipient type. +type RecipientType string + +const ( + // Admin ... + Admin RecipientType = "Admin" + // Approver ... + Approver RecipientType = "Approver" + // Requestor ... + Requestor RecipientType = "Requestor" +) + +// PossibleRecipientTypeValues returns an array of possible values for the RecipientType const type. +func PossibleRecipientTypeValues() []RecipientType { + return []RecipientType{Admin, Approver, Requestor} +} + +// RequestType enumerates the values for request type. +type RequestType string + +const ( + // AdminAssign ... + AdminAssign RequestType = "AdminAssign" + // AdminExtend ... + AdminExtend RequestType = "AdminExtend" + // AdminRemove ... + AdminRemove RequestType = "AdminRemove" + // AdminRenew ... + AdminRenew RequestType = "AdminRenew" + // AdminUpdate ... + AdminUpdate RequestType = "AdminUpdate" + // SelfActivate ... + SelfActivate RequestType = "SelfActivate" + // SelfDeactivate ... + SelfDeactivate RequestType = "SelfDeactivate" + // SelfExtend ... + SelfExtend RequestType = "SelfExtend" + // SelfRenew ... + SelfRenew RequestType = "SelfRenew" +) + +// PossibleRequestTypeValues returns an array of possible values for the RequestType const type. +func PossibleRequestTypeValues() []RequestType { + return []RequestType{AdminAssign, AdminExtend, AdminRemove, AdminRenew, AdminUpdate, SelfActivate, SelfDeactivate, SelfExtend, SelfRenew} +} + +// RoleManagementPolicyRuleType enumerates the values for role management policy rule type. +type RoleManagementPolicyRuleType string + +const ( + // RoleManagementPolicyRuleTypeRoleManagementPolicyApprovalRule ... + RoleManagementPolicyRuleTypeRoleManagementPolicyApprovalRule RoleManagementPolicyRuleType = "RoleManagementPolicyApprovalRule" + // RoleManagementPolicyRuleTypeRoleManagementPolicyAuthenticationContextRule ... + RoleManagementPolicyRuleTypeRoleManagementPolicyAuthenticationContextRule RoleManagementPolicyRuleType = "RoleManagementPolicyAuthenticationContextRule" + // RoleManagementPolicyRuleTypeRoleManagementPolicyEnablementRule ... + RoleManagementPolicyRuleTypeRoleManagementPolicyEnablementRule RoleManagementPolicyRuleType = "RoleManagementPolicyEnablementRule" + // RoleManagementPolicyRuleTypeRoleManagementPolicyExpirationRule ... + RoleManagementPolicyRuleTypeRoleManagementPolicyExpirationRule RoleManagementPolicyRuleType = "RoleManagementPolicyExpirationRule" + // RoleManagementPolicyRuleTypeRoleManagementPolicyNotificationRule ... + RoleManagementPolicyRuleTypeRoleManagementPolicyNotificationRule RoleManagementPolicyRuleType = "RoleManagementPolicyNotificationRule" +) + +// PossibleRoleManagementPolicyRuleTypeValues returns an array of possible values for the RoleManagementPolicyRuleType const type. +func PossibleRoleManagementPolicyRuleTypeValues() []RoleManagementPolicyRuleType { + return []RoleManagementPolicyRuleType{RoleManagementPolicyRuleTypeRoleManagementPolicyApprovalRule, RoleManagementPolicyRuleTypeRoleManagementPolicyAuthenticationContextRule, RoleManagementPolicyRuleTypeRoleManagementPolicyEnablementRule, RoleManagementPolicyRuleTypeRoleManagementPolicyExpirationRule, RoleManagementPolicyRuleTypeRoleManagementPolicyNotificationRule} +} + +// RuleType enumerates the values for rule type. +type RuleType string + +const ( + // RuleTypeRoleManagementPolicyApprovalRule ... + RuleTypeRoleManagementPolicyApprovalRule RuleType = "RoleManagementPolicyApprovalRule" + // RuleTypeRoleManagementPolicyAuthenticationContextRule ... + RuleTypeRoleManagementPolicyAuthenticationContextRule RuleType = "RoleManagementPolicyAuthenticationContextRule" + // RuleTypeRoleManagementPolicyEnablementRule ... + RuleTypeRoleManagementPolicyEnablementRule RuleType = "RoleManagementPolicyEnablementRule" + // RuleTypeRoleManagementPolicyExpirationRule ... + RuleTypeRoleManagementPolicyExpirationRule RuleType = "RoleManagementPolicyExpirationRule" + // RuleTypeRoleManagementPolicyNotificationRule ... + RuleTypeRoleManagementPolicyNotificationRule RuleType = "RoleManagementPolicyNotificationRule" + // RuleTypeRoleManagementPolicyRule ... + RuleTypeRoleManagementPolicyRule RuleType = "RoleManagementPolicyRule" +) + +// PossibleRuleTypeValues returns an array of possible values for the RuleType const type. +func PossibleRuleTypeValues() []RuleType { + return []RuleType{RuleTypeRoleManagementPolicyApprovalRule, RuleTypeRoleManagementPolicyAuthenticationContextRule, RuleTypeRoleManagementPolicyEnablementRule, RuleTypeRoleManagementPolicyExpirationRule, RuleTypeRoleManagementPolicyNotificationRule, RuleTypeRoleManagementPolicyRule} +} + +// Status enumerates the values for status. +type Status string + +const ( + // Accepted ... + Accepted Status = "Accepted" + // AdminApproved ... + AdminApproved Status = "AdminApproved" + // AdminDenied ... + AdminDenied Status = "AdminDenied" + // Canceled ... + Canceled Status = "Canceled" + // Denied ... + Denied Status = "Denied" + // Failed ... + Failed Status = "Failed" + // FailedAsResourceIsLocked ... + FailedAsResourceIsLocked Status = "FailedAsResourceIsLocked" + // Granted ... + Granted Status = "Granted" + // Invalid ... + Invalid Status = "Invalid" + // PendingAdminDecision ... + PendingAdminDecision Status = "PendingAdminDecision" + // PendingApproval ... + PendingApproval Status = "PendingApproval" + // PendingApprovalProvisioning ... + PendingApprovalProvisioning Status = "PendingApprovalProvisioning" + // PendingEvaluation ... + PendingEvaluation Status = "PendingEvaluation" + // PendingExternalProvisioning ... + PendingExternalProvisioning Status = "PendingExternalProvisioning" + // PendingProvisioning ... + PendingProvisioning Status = "PendingProvisioning" + // PendingRevocation ... + PendingRevocation Status = "PendingRevocation" + // PendingScheduleCreation ... + PendingScheduleCreation Status = "PendingScheduleCreation" + // Provisioned ... + Provisioned Status = "Provisioned" + // ProvisioningStarted ... + ProvisioningStarted Status = "ProvisioningStarted" + // Revoked ... + Revoked Status = "Revoked" + // ScheduleCreated ... + ScheduleCreated Status = "ScheduleCreated" + // TimedOut ... + TimedOut Status = "TimedOut" +) + +// PossibleStatusValues returns an array of possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{Accepted, AdminApproved, AdminDenied, Canceled, Denied, Failed, FailedAsResourceIsLocked, Granted, Invalid, PendingAdminDecision, PendingApproval, PendingApprovalProvisioning, PendingEvaluation, PendingExternalProvisioning, PendingProvisioning, PendingRevocation, PendingScheduleCreation, Provisioned, ProvisioningStarted, Revoked, ScheduleCreated, TimedOut} +} + +// Type enumerates the values for type. +type Type string + +const ( + // AfterDateTime ... + AfterDateTime Type = "AfterDateTime" + // AfterDuration ... + AfterDuration Type = "AfterDuration" + // NoExpiration ... + NoExpiration Type = "NoExpiration" +) + +// PossibleTypeValues returns an array of possible values for the Type const type. +func PossibleTypeValues() []Type { + return []Type{AfterDateTime, AfterDuration, NoExpiration} +} + +// TypeBasicAccessReviewDecisionTarget enumerates the values for type basic access review decision target. +type TypeBasicAccessReviewDecisionTarget string + +const ( + // TypeAccessReviewDecisionTarget ... + TypeAccessReviewDecisionTarget TypeBasicAccessReviewDecisionTarget = "AccessReviewDecisionTarget" + // TypeServicePrincipal ... + TypeServicePrincipal TypeBasicAccessReviewDecisionTarget = "servicePrincipal" + // TypeUser ... + TypeUser TypeBasicAccessReviewDecisionTarget = "user" +) + +// PossibleTypeBasicAccessReviewDecisionTargetValues returns an array of possible values for the TypeBasicAccessReviewDecisionTarget const type. +func PossibleTypeBasicAccessReviewDecisionTargetValues() []TypeBasicAccessReviewDecisionTarget { + return []TypeBasicAccessReviewDecisionTarget{TypeAccessReviewDecisionTarget, TypeServicePrincipal, TypeUser} +} + +// UserType enumerates the values for user type. +type UserType string + +const ( + // UserTypeGroup ... + UserTypeGroup UserType = "Group" + // UserTypeUser ... + UserTypeUser UserType = "User" +) + +// PossibleUserTypeValues returns an array of possible values for the UserType const type. +func PossibleUserTypeValues() []UserType { + return []UserType{UserTypeGroup, UserTypeUser} +} diff --git a/services/preview/authorization/mgmt/2020-10-01-preview/authorization/models.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/models.go new file mode 100644 index 000000000000..25ad92679c2d --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/models.go @@ -0,0 +1,6370 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2020-10-01-preview/authorization" + +// AccessReviewActorIdentity details of the actor identity +type AccessReviewActorIdentity struct { + // PrincipalID - READ-ONLY; The identity id + PrincipalID *string `json:"principalId,omitempty"` + // PrincipalType - READ-ONLY; The identity type : user/servicePrincipal. Possible values include: 'User', 'ServicePrincipal' + PrincipalType AccessReviewActorIdentityType `json:"principalType,omitempty"` + // PrincipalName - READ-ONLY; The identity display name + PrincipalName *string `json:"principalName,omitempty"` + // UserPrincipalName - READ-ONLY; The user principal name(if valid) + UserPrincipalName *string `json:"userPrincipalName,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccessReviewActorIdentity. +func (arai AccessReviewActorIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// AccessReviewDecision access Review. +type AccessReviewDecision struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The access review decision id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The access review decision name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // AccessReviewDecisionProperties - Access Review Decision properties. + *AccessReviewDecisionProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccessReviewDecision. +func (ard AccessReviewDecision) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ard.AccessReviewDecisionProperties != nil { + objectMap["properties"] = ard.AccessReviewDecisionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AccessReviewDecision struct. +func (ard *AccessReviewDecision) 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 + } + ard.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ard.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ard.Type = &typeVar + } + case "properties": + if v != nil { + var accessReviewDecisionProperties AccessReviewDecisionProperties + err = json.Unmarshal(*v, &accessReviewDecisionProperties) + if err != nil { + return err + } + ard.AccessReviewDecisionProperties = &accessReviewDecisionProperties + } + } + } + + return nil +} + +// AccessReviewDecisionListResult list of access review decisions. +type AccessReviewDecisionListResult struct { + autorest.Response `json:"-"` + // Value - Access Review Decision list. + Value *[]AccessReviewDecision `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// AccessReviewDecisionListResultIterator provides access to a complete listing of AccessReviewDecision +// values. +type AccessReviewDecisionListResultIterator struct { + i int + page AccessReviewDecisionListResultPage +} + +// 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 *AccessReviewDecisionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewDecisionListResultIterator.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 *AccessReviewDecisionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AccessReviewDecisionListResultIterator) 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 AccessReviewDecisionListResultIterator) Response() AccessReviewDecisionListResult { + 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 AccessReviewDecisionListResultIterator) Value() AccessReviewDecision { + if !iter.page.NotDone() { + return AccessReviewDecision{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AccessReviewDecisionListResultIterator type. +func NewAccessReviewDecisionListResultIterator(page AccessReviewDecisionListResultPage) AccessReviewDecisionListResultIterator { + return AccessReviewDecisionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ardlr AccessReviewDecisionListResult) IsEmpty() bool { + return ardlr.Value == nil || len(*ardlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ardlr AccessReviewDecisionListResult) hasNextLink() bool { + return ardlr.NextLink != nil && len(*ardlr.NextLink) != 0 +} + +// accessReviewDecisionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ardlr AccessReviewDecisionListResult) accessReviewDecisionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ardlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ardlr.NextLink))) +} + +// AccessReviewDecisionListResultPage contains a page of AccessReviewDecision values. +type AccessReviewDecisionListResultPage struct { + fn func(context.Context, AccessReviewDecisionListResult) (AccessReviewDecisionListResult, error) + ardlr AccessReviewDecisionListResult +} + +// 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 *AccessReviewDecisionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewDecisionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ardlr) + if err != nil { + return err + } + page.ardlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AccessReviewDecisionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AccessReviewDecisionListResultPage) NotDone() bool { + return !page.ardlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AccessReviewDecisionListResultPage) Response() AccessReviewDecisionListResult { + return page.ardlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AccessReviewDecisionListResultPage) Values() []AccessReviewDecision { + if page.ardlr.IsEmpty() { + return nil + } + return *page.ardlr.Value +} + +// Creates a new instance of the AccessReviewDecisionListResultPage type. +func NewAccessReviewDecisionListResultPage(cur AccessReviewDecisionListResult, getNextPage func(context.Context, AccessReviewDecisionListResult) (AccessReviewDecisionListResult, error)) AccessReviewDecisionListResultPage { + return AccessReviewDecisionListResultPage{ + fn: getNextPage, + ardlr: cur, + } +} + +// AccessReviewDecisionProperties approval Step. +type AccessReviewDecisionProperties struct { + // BasicAccessReviewDecisionTarget - READ-ONLY; Target of this decision record. Can be UserDecisionTarget or ServicePrincipalDecisionTarget + BasicAccessReviewDecisionTarget `json:"target,omitempty"` + // Recommendation - READ-ONLY; The feature- generated recommendation shown to the reviewer. Possible values include: 'Approve', 'Deny', 'NoInfoAvailable' + Recommendation AccessRecommendationType `json:"recommendation,omitempty"` + // Decision - The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Possible values include: 'AccessReviewResultApprove', 'AccessReviewResultDeny', 'AccessReviewResultNotReviewed', 'AccessReviewResultDontKnow', 'AccessReviewResultNotNotified' + Decision AccessReviewResult `json:"decision,omitempty"` + // Justification - Justification provided by approvers for their action + Justification *string `json:"justification,omitempty"` + // ReviewedDateTime - READ-ONLY; Date Time when a decision was taken. + ReviewedDateTime *date.Time `json:"reviewedDateTime,omitempty"` + // AccessReviewActorIdentity - READ-ONLY; Details of the approver. + *AccessReviewActorIdentity `json:"reviewedBy,omitempty"` + // ApplyResult - READ-ONLY; The outcome of applying the decision. Possible values include: 'AccessReviewApplyResultNew', 'AccessReviewApplyResultApplying', 'AccessReviewApplyResultAppliedSuccessfully', 'AccessReviewApplyResultAppliedWithUnknownFailure', 'AccessReviewApplyResultAppliedSuccessfullyButObjectNotFound', 'AccessReviewApplyResultApplyNotSupported' + ApplyResult AccessReviewApplyResult `json:"applyResult,omitempty"` + // AppliedDateTime - READ-ONLY; The date and time when the review decision was applied. + AppliedDateTime *date.Time `json:"appliedDateTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccessReviewDecisionProperties. +func (ardp AccessReviewDecisionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ardp.Decision != "" { + objectMap["decision"] = ardp.Decision + } + if ardp.Justification != nil { + objectMap["justification"] = ardp.Justification + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AccessReviewDecisionProperties struct. +func (ardp *AccessReviewDecisionProperties) 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 "target": + if v != nil { + basicAccessReviewDecisionTarget, err := unmarshalBasicAccessReviewDecisionTarget(*v) + if err != nil { + return err + } + ardp.BasicAccessReviewDecisionTarget = basicAccessReviewDecisionTarget + } + case "recommendation": + if v != nil { + var recommendation AccessRecommendationType + err = json.Unmarshal(*v, &recommendation) + if err != nil { + return err + } + ardp.Recommendation = recommendation + } + case "decision": + if v != nil { + var decision AccessReviewResult + err = json.Unmarshal(*v, &decision) + if err != nil { + return err + } + ardp.Decision = decision + } + case "justification": + if v != nil { + var justification string + err = json.Unmarshal(*v, &justification) + if err != nil { + return err + } + ardp.Justification = &justification + } + case "reviewedDateTime": + if v != nil { + var reviewedDateTime date.Time + err = json.Unmarshal(*v, &reviewedDateTime) + if err != nil { + return err + } + ardp.ReviewedDateTime = &reviewedDateTime + } + case "reviewedBy": + if v != nil { + var accessReviewActorIdentity AccessReviewActorIdentity + err = json.Unmarshal(*v, &accessReviewActorIdentity) + if err != nil { + return err + } + ardp.AccessReviewActorIdentity = &accessReviewActorIdentity + } + case "applyResult": + if v != nil { + var applyResult AccessReviewApplyResult + err = json.Unmarshal(*v, &applyResult) + if err != nil { + return err + } + ardp.ApplyResult = applyResult + } + case "appliedDateTime": + if v != nil { + var appliedDateTime date.Time + err = json.Unmarshal(*v, &appliedDateTime) + if err != nil { + return err + } + ardp.AppliedDateTime = &appliedDateTime + } + case "appliedBy": + if v != nil { + var accessReviewActorIdentity1 AccessReviewActorIdentity + err = json.Unmarshal(*v, &accessReviewActorIdentity1) + if err != nil { + return err + } + ardp.AccessReviewActorIdentity = &accessReviewActorIdentity1 + } + } + } + + return nil +} + +// BasicAccessReviewDecisionTarget target of the decision. +type BasicAccessReviewDecisionTarget interface { + AsUserDecisionTarget() (*UserDecisionTarget, bool) + AsServicePrincipalDecisionTarget() (*ServicePrincipalDecisionTarget, bool) + AsAccessReviewDecisionTarget() (*AccessReviewDecisionTarget, bool) +} + +// AccessReviewDecisionTarget target of the decision. +type AccessReviewDecisionTarget struct { + // Type - Possible values include: 'TypeAccessReviewDecisionTarget', 'TypeUser', 'TypeServicePrincipal' + Type TypeBasicAccessReviewDecisionTarget `json:"type,omitempty"` +} + +func unmarshalBasicAccessReviewDecisionTarget(body []byte) (BasicAccessReviewDecisionTarget, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["type"] { + case string(TypeUser): + var udt UserDecisionTarget + err := json.Unmarshal(body, &udt) + return udt, err + case string(TypeServicePrincipal): + var spdt ServicePrincipalDecisionTarget + err := json.Unmarshal(body, &spdt) + return spdt, err + default: + var ardt AccessReviewDecisionTarget + err := json.Unmarshal(body, &ardt) + return ardt, err + } +} +func unmarshalBasicAccessReviewDecisionTargetArray(body []byte) ([]BasicAccessReviewDecisionTarget, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + ardtArray := make([]BasicAccessReviewDecisionTarget, len(rawMessages)) + + for index, rawMessage := range rawMessages { + ardt, err := unmarshalBasicAccessReviewDecisionTarget(*rawMessage) + if err != nil { + return nil, err + } + ardtArray[index] = ardt + } + return ardtArray, nil +} + +// MarshalJSON is the custom marshaler for AccessReviewDecisionTarget. +func (ardt AccessReviewDecisionTarget) MarshalJSON() ([]byte, error) { + ardt.Type = TypeAccessReviewDecisionTarget + objectMap := make(map[string]interface{}) + if ardt.Type != "" { + objectMap["type"] = ardt.Type + } + return json.Marshal(objectMap) +} + +// AsUserDecisionTarget is the BasicAccessReviewDecisionTarget implementation for AccessReviewDecisionTarget. +func (ardt AccessReviewDecisionTarget) AsUserDecisionTarget() (*UserDecisionTarget, bool) { + return nil, false +} + +// AsServicePrincipalDecisionTarget is the BasicAccessReviewDecisionTarget implementation for AccessReviewDecisionTarget. +func (ardt AccessReviewDecisionTarget) AsServicePrincipalDecisionTarget() (*ServicePrincipalDecisionTarget, bool) { + return nil, false +} + +// AsAccessReviewDecisionTarget is the BasicAccessReviewDecisionTarget implementation for AccessReviewDecisionTarget. +func (ardt AccessReviewDecisionTarget) AsAccessReviewDecisionTarget() (*AccessReviewDecisionTarget, bool) { + return &ardt, true +} + +// AsBasicAccessReviewDecisionTarget is the BasicAccessReviewDecisionTarget implementation for AccessReviewDecisionTarget. +func (ardt AccessReviewDecisionTarget) AsBasicAccessReviewDecisionTarget() (BasicAccessReviewDecisionTarget, bool) { + return &ardt, true +} + +// AccessReviewDefaultSettings access Review Default Settings. +type AccessReviewDefaultSettings struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The access review default settings id. This is only going to be default + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The access review default settings name. This is always going to be Access Review Default Settings + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // AccessReviewScheduleSettings - Access Review properties. + *AccessReviewScheduleSettings `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccessReviewDefaultSettings. +func (ards AccessReviewDefaultSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ards.AccessReviewScheduleSettings != nil { + objectMap["properties"] = ards.AccessReviewScheduleSettings + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AccessReviewDefaultSettings struct. +func (ards *AccessReviewDefaultSettings) 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 + } + ards.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ards.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ards.Type = &typeVar + } + case "properties": + if v != nil { + var accessReviewScheduleSettings AccessReviewScheduleSettings + err = json.Unmarshal(*v, &accessReviewScheduleSettings) + if err != nil { + return err + } + ards.AccessReviewScheduleSettings = &accessReviewScheduleSettings + } + } + } + + return nil +} + +// AccessReviewInstance access Review Instance. +type AccessReviewInstance struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The access review instance id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The access review instance name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // AccessReviewInstanceProperties - Access Review properties. + *AccessReviewInstanceProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccessReviewInstance. +func (ari AccessReviewInstance) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ari.AccessReviewInstanceProperties != nil { + objectMap["properties"] = ari.AccessReviewInstanceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AccessReviewInstance struct. +func (ari *AccessReviewInstance) 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 + } + ari.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ari.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ari.Type = &typeVar + } + case "properties": + if v != nil { + var accessReviewInstanceProperties AccessReviewInstanceProperties + err = json.Unmarshal(*v, &accessReviewInstanceProperties) + if err != nil { + return err + } + ari.AccessReviewInstanceProperties = &accessReviewInstanceProperties + } + } + } + + return nil +} + +// AccessReviewInstanceListResult list of Access Review Instances. +type AccessReviewInstanceListResult struct { + autorest.Response `json:"-"` + // Value - Access Review Instance list. + Value *[]AccessReviewInstance `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// AccessReviewInstanceListResultIterator provides access to a complete listing of AccessReviewInstance +// values. +type AccessReviewInstanceListResultIterator struct { + i int + page AccessReviewInstanceListResultPage +} + +// 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 *AccessReviewInstanceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewInstanceListResultIterator.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 *AccessReviewInstanceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AccessReviewInstanceListResultIterator) 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 AccessReviewInstanceListResultIterator) Response() AccessReviewInstanceListResult { + 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 AccessReviewInstanceListResultIterator) Value() AccessReviewInstance { + if !iter.page.NotDone() { + return AccessReviewInstance{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AccessReviewInstanceListResultIterator type. +func NewAccessReviewInstanceListResultIterator(page AccessReviewInstanceListResultPage) AccessReviewInstanceListResultIterator { + return AccessReviewInstanceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (arilr AccessReviewInstanceListResult) IsEmpty() bool { + return arilr.Value == nil || len(*arilr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (arilr AccessReviewInstanceListResult) hasNextLink() bool { + return arilr.NextLink != nil && len(*arilr.NextLink) != 0 +} + +// accessReviewInstanceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (arilr AccessReviewInstanceListResult) accessReviewInstanceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !arilr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(arilr.NextLink))) +} + +// AccessReviewInstanceListResultPage contains a page of AccessReviewInstance values. +type AccessReviewInstanceListResultPage struct { + fn func(context.Context, AccessReviewInstanceListResult) (AccessReviewInstanceListResult, error) + arilr AccessReviewInstanceListResult +} + +// 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 *AccessReviewInstanceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewInstanceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.arilr) + if err != nil { + return err + } + page.arilr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AccessReviewInstanceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AccessReviewInstanceListResultPage) NotDone() bool { + return !page.arilr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AccessReviewInstanceListResultPage) Response() AccessReviewInstanceListResult { + return page.arilr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AccessReviewInstanceListResultPage) Values() []AccessReviewInstance { + if page.arilr.IsEmpty() { + return nil + } + return *page.arilr.Value +} + +// Creates a new instance of the AccessReviewInstanceListResultPage type. +func NewAccessReviewInstanceListResultPage(cur AccessReviewInstanceListResult, getNextPage func(context.Context, AccessReviewInstanceListResult) (AccessReviewInstanceListResult, error)) AccessReviewInstanceListResultPage { + return AccessReviewInstanceListResultPage{ + fn: getNextPage, + arilr: cur, + } +} + +// AccessReviewInstanceProperties access Review Instance properties. +type AccessReviewInstanceProperties struct { + // Status - READ-ONLY; This read-only field specifies the status of an access review instance. Possible values include: 'NotStarted', 'InProgress', 'Completed', 'Applied', 'Initializing', 'Applying', 'Completing', 'Scheduled', 'AutoReviewing', 'AutoReviewed', 'Starting' + Status AccessReviewInstanceStatus `json:"status,omitempty"` + // StartDateTime - The DateTime when the review instance is scheduled to be start. + StartDateTime *date.Time `json:"startDateTime,omitempty"` + // EndDateTime - The DateTime when the review instance is scheduled to end. + EndDateTime *date.Time `json:"endDateTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccessReviewInstanceProperties. +func (arip AccessReviewInstanceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if arip.StartDateTime != nil { + objectMap["startDateTime"] = arip.StartDateTime + } + if arip.EndDateTime != nil { + objectMap["endDateTime"] = arip.EndDateTime + } + return json.Marshal(objectMap) +} + +// AccessReviewRecurrencePattern recurrence Pattern of an Access Review Schedule Definition. +type AccessReviewRecurrencePattern struct { + // Type - The recurrence type : weekly, monthly, etc. Possible values include: 'Weekly', 'AbsoluteMonthly' + Type AccessReviewRecurrencePatternType `json:"type,omitempty"` + // Interval - The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. + Interval *int32 `json:"interval,omitempty"` +} + +// AccessReviewRecurrenceRange recurrence Range of an Access Review Schedule Definition. +type AccessReviewRecurrenceRange struct { + // Type - The recurrence range type. The possible values are: endDate, noEnd, numbered. Possible values include: 'EndDate', 'NoEnd', 'Numbered' + Type AccessReviewRecurrenceRangeType `json:"type,omitempty"` + // NumberOfOccurrences - The number of times to repeat the access review. Required and must be positive if type is numbered. + NumberOfOccurrences *int32 `json:"numberOfOccurrences,omitempty"` + // StartDate - The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. + StartDate *date.Time `json:"startDate,omitempty"` + // EndDate - The DateTime when the review is scheduled to end. Required if type is endDate + EndDate *date.Time `json:"endDate,omitempty"` +} + +// AccessReviewRecurrenceSettings recurrence Settings of an Access Review Schedule Definition. +type AccessReviewRecurrenceSettings struct { + // AccessReviewRecurrencePattern - Access Review schedule definition recurrence pattern. + *AccessReviewRecurrencePattern `json:"pattern,omitempty"` + // AccessReviewRecurrenceRange - Access Review schedule definition recurrence range. + *AccessReviewRecurrenceRange `json:"range,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccessReviewRecurrenceSettings. +func (arrs AccessReviewRecurrenceSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if arrs.AccessReviewRecurrencePattern != nil { + objectMap["pattern"] = arrs.AccessReviewRecurrencePattern + } + if arrs.AccessReviewRecurrenceRange != nil { + objectMap["range"] = arrs.AccessReviewRecurrenceRange + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AccessReviewRecurrenceSettings struct. +func (arrs *AccessReviewRecurrenceSettings) 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 "pattern": + if v != nil { + var accessReviewRecurrencePattern AccessReviewRecurrencePattern + err = json.Unmarshal(*v, &accessReviewRecurrencePattern) + if err != nil { + return err + } + arrs.AccessReviewRecurrencePattern = &accessReviewRecurrencePattern + } + case "range": + if v != nil { + var accessReviewRecurrenceRange AccessReviewRecurrenceRange + err = json.Unmarshal(*v, &accessReviewRecurrenceRange) + if err != nil { + return err + } + arrs.AccessReviewRecurrenceRange = &accessReviewRecurrenceRange + } + } + } + + return nil +} + +// AccessReviewReviewer descriptor for what needs to be reviewed +type AccessReviewReviewer struct { + // PrincipalID - The id of the reviewer(user/servicePrincipal) + PrincipalID *string `json:"principalId,omitempty"` + // PrincipalType - READ-ONLY; The identity type : user/servicePrincipal. Possible values include: 'AccessReviewReviewerTypeUser', 'AccessReviewReviewerTypeServicePrincipal' + PrincipalType AccessReviewReviewerType `json:"principalType,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccessReviewReviewer. +func (arr AccessReviewReviewer) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if arr.PrincipalID != nil { + objectMap["principalId"] = arr.PrincipalID + } + return json.Marshal(objectMap) +} + +// AccessReviewScheduleDefinition access Review Schedule Definition. +type AccessReviewScheduleDefinition struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The access review schedule definition id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The access review schedule definition unique id. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // AccessReviewScheduleDefinitionProperties - Access Review properties. + *AccessReviewScheduleDefinitionProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccessReviewScheduleDefinition. +func (arsd AccessReviewScheduleDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if arsd.AccessReviewScheduleDefinitionProperties != nil { + objectMap["properties"] = arsd.AccessReviewScheduleDefinitionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AccessReviewScheduleDefinition struct. +func (arsd *AccessReviewScheduleDefinition) 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 + } + arsd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + arsd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + arsd.Type = &typeVar + } + case "properties": + if v != nil { + var accessReviewScheduleDefinitionProperties AccessReviewScheduleDefinitionProperties + err = json.Unmarshal(*v, &accessReviewScheduleDefinitionProperties) + if err != nil { + return err + } + arsd.AccessReviewScheduleDefinitionProperties = &accessReviewScheduleDefinitionProperties + } + } + } + + return nil +} + +// AccessReviewScheduleDefinitionListResult list of Access Review Schedule Definitions. +type AccessReviewScheduleDefinitionListResult struct { + autorest.Response `json:"-"` + // Value - Access Review Schedule Definition list. + Value *[]AccessReviewScheduleDefinition `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// AccessReviewScheduleDefinitionListResultIterator provides access to a complete listing of +// AccessReviewScheduleDefinition values. +type AccessReviewScheduleDefinitionListResultIterator struct { + i int + page AccessReviewScheduleDefinitionListResultPage +} + +// 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 *AccessReviewScheduleDefinitionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewScheduleDefinitionListResultIterator.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 *AccessReviewScheduleDefinitionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AccessReviewScheduleDefinitionListResultIterator) 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 AccessReviewScheduleDefinitionListResultIterator) Response() AccessReviewScheduleDefinitionListResult { + 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 AccessReviewScheduleDefinitionListResultIterator) Value() AccessReviewScheduleDefinition { + if !iter.page.NotDone() { + return AccessReviewScheduleDefinition{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AccessReviewScheduleDefinitionListResultIterator type. +func NewAccessReviewScheduleDefinitionListResultIterator(page AccessReviewScheduleDefinitionListResultPage) AccessReviewScheduleDefinitionListResultIterator { + return AccessReviewScheduleDefinitionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (arsdlr AccessReviewScheduleDefinitionListResult) IsEmpty() bool { + return arsdlr.Value == nil || len(*arsdlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (arsdlr AccessReviewScheduleDefinitionListResult) hasNextLink() bool { + return arsdlr.NextLink != nil && len(*arsdlr.NextLink) != 0 +} + +// accessReviewScheduleDefinitionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (arsdlr AccessReviewScheduleDefinitionListResult) accessReviewScheduleDefinitionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !arsdlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(arsdlr.NextLink))) +} + +// AccessReviewScheduleDefinitionListResultPage contains a page of AccessReviewScheduleDefinition values. +type AccessReviewScheduleDefinitionListResultPage struct { + fn func(context.Context, AccessReviewScheduleDefinitionListResult) (AccessReviewScheduleDefinitionListResult, error) + arsdlr AccessReviewScheduleDefinitionListResult +} + +// 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 *AccessReviewScheduleDefinitionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessReviewScheduleDefinitionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.arsdlr) + if err != nil { + return err + } + page.arsdlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AccessReviewScheduleDefinitionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AccessReviewScheduleDefinitionListResultPage) NotDone() bool { + return !page.arsdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AccessReviewScheduleDefinitionListResultPage) Response() AccessReviewScheduleDefinitionListResult { + return page.arsdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AccessReviewScheduleDefinitionListResultPage) Values() []AccessReviewScheduleDefinition { + if page.arsdlr.IsEmpty() { + return nil + } + return *page.arsdlr.Value +} + +// Creates a new instance of the AccessReviewScheduleDefinitionListResultPage type. +func NewAccessReviewScheduleDefinitionListResultPage(cur AccessReviewScheduleDefinitionListResult, getNextPage func(context.Context, AccessReviewScheduleDefinitionListResult) (AccessReviewScheduleDefinitionListResult, error)) AccessReviewScheduleDefinitionListResultPage { + return AccessReviewScheduleDefinitionListResultPage{ + fn: getNextPage, + arsdlr: cur, + } +} + +// AccessReviewScheduleDefinitionProperties access Review. +type AccessReviewScheduleDefinitionProperties struct { + // DisplayName - The display name for the schedule definition. + DisplayName *string `json:"displayName,omitempty"` + // Status - READ-ONLY; This read-only field specifies the status of an accessReview. Possible values include: 'AccessReviewScheduleDefinitionStatusNotStarted', 'AccessReviewScheduleDefinitionStatusInProgress', 'AccessReviewScheduleDefinitionStatusCompleted', 'AccessReviewScheduleDefinitionStatusApplied', 'AccessReviewScheduleDefinitionStatusInitializing', 'AccessReviewScheduleDefinitionStatusApplying', 'AccessReviewScheduleDefinitionStatusCompleting', 'AccessReviewScheduleDefinitionStatusScheduled', 'AccessReviewScheduleDefinitionStatusAutoReviewing', 'AccessReviewScheduleDefinitionStatusAutoReviewed', 'AccessReviewScheduleDefinitionStatusStarting' + Status AccessReviewScheduleDefinitionStatus `json:"status,omitempty"` + // DescriptionForAdmins - The description provided by the access review creator and visible to admins. + DescriptionForAdmins *string `json:"descriptionForAdmins,omitempty"` + // DescriptionForReviewers - The description provided by the access review creator to be shown to reviewers. + DescriptionForReviewers *string `json:"descriptionForReviewers,omitempty"` + // AccessReviewActorIdentity - READ-ONLY; The user or other identity who created this review. + *AccessReviewActorIdentity `json:"createdBy,omitempty"` + // AccessReviewScheduleSettings - Access Review Settings. + *AccessReviewScheduleSettings `json:"settings,omitempty"` + // AccessReviewScope - READ-ONLY; This is used to define what to include in scope of the review. The scope definition includes the resourceId and roleDefinitionId. + *AccessReviewScope `json:"scope,omitempty"` + // Reviewers - This is the collection of reviewers. + Reviewers *[]AccessReviewReviewer `json:"reviewers,omitempty"` + // ReviewersType - READ-ONLY; This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be assigned and instead be chosen dynamically. For example managers review or self review. Possible values include: 'Assigned', 'Self', 'Managers' + ReviewersType AccessReviewScheduleDefinitionReviewersType `json:"reviewersType,omitempty"` + // Instances - This is the collection of instances returned when one does an expand on it. + Instances *[]AccessReviewInstance `json:"instances,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccessReviewScheduleDefinitionProperties. +func (arsdp AccessReviewScheduleDefinitionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if arsdp.DisplayName != nil { + objectMap["displayName"] = arsdp.DisplayName + } + if arsdp.DescriptionForAdmins != nil { + objectMap["descriptionForAdmins"] = arsdp.DescriptionForAdmins + } + if arsdp.DescriptionForReviewers != nil { + objectMap["descriptionForReviewers"] = arsdp.DescriptionForReviewers + } + if arsdp.AccessReviewScheduleSettings != nil { + objectMap["settings"] = arsdp.AccessReviewScheduleSettings + } + if arsdp.Reviewers != nil { + objectMap["reviewers"] = arsdp.Reviewers + } + if arsdp.Instances != nil { + objectMap["instances"] = arsdp.Instances + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AccessReviewScheduleDefinitionProperties struct. +func (arsdp *AccessReviewScheduleDefinitionProperties) 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 "displayName": + if v != nil { + var displayName string + err = json.Unmarshal(*v, &displayName) + if err != nil { + return err + } + arsdp.DisplayName = &displayName + } + case "status": + if v != nil { + var status AccessReviewScheduleDefinitionStatus + err = json.Unmarshal(*v, &status) + if err != nil { + return err + } + arsdp.Status = status + } + case "descriptionForAdmins": + if v != nil { + var descriptionForAdmins string + err = json.Unmarshal(*v, &descriptionForAdmins) + if err != nil { + return err + } + arsdp.DescriptionForAdmins = &descriptionForAdmins + } + case "descriptionForReviewers": + if v != nil { + var descriptionForReviewers string + err = json.Unmarshal(*v, &descriptionForReviewers) + if err != nil { + return err + } + arsdp.DescriptionForReviewers = &descriptionForReviewers + } + case "createdBy": + if v != nil { + var accessReviewActorIdentity AccessReviewActorIdentity + err = json.Unmarshal(*v, &accessReviewActorIdentity) + if err != nil { + return err + } + arsdp.AccessReviewActorIdentity = &accessReviewActorIdentity + } + case "settings": + if v != nil { + var accessReviewScheduleSettings AccessReviewScheduleSettings + err = json.Unmarshal(*v, &accessReviewScheduleSettings) + if err != nil { + return err + } + arsdp.AccessReviewScheduleSettings = &accessReviewScheduleSettings + } + case "scope": + if v != nil { + var accessReviewScope AccessReviewScope + err = json.Unmarshal(*v, &accessReviewScope) + if err != nil { + return err + } + arsdp.AccessReviewScope = &accessReviewScope + } + case "reviewers": + if v != nil { + var reviewers []AccessReviewReviewer + err = json.Unmarshal(*v, &reviewers) + if err != nil { + return err + } + arsdp.Reviewers = &reviewers + } + case "reviewersType": + if v != nil { + var reviewersType AccessReviewScheduleDefinitionReviewersType + err = json.Unmarshal(*v, &reviewersType) + if err != nil { + return err + } + arsdp.ReviewersType = reviewersType + } + case "instances": + if v != nil { + var instances []AccessReviewInstance + err = json.Unmarshal(*v, &instances) + if err != nil { + return err + } + arsdp.Instances = &instances + } + } + } + + return nil +} + +// AccessReviewScheduleSettings settings of an Access Review. +type AccessReviewScheduleSettings struct { + // MailNotificationsEnabled - Flag to indicate whether sending mails to reviewers and the review creator is enabled. + MailNotificationsEnabled *bool `json:"mailNotificationsEnabled,omitempty"` + // ReminderNotificationsEnabled - Flag to indicate whether sending reminder emails to reviewers are enabled. + ReminderNotificationsEnabled *bool `json:"reminderNotificationsEnabled,omitempty"` + // DefaultDecisionEnabled - Flag to indicate whether reviewers are required to provide a justification when reviewing access. + DefaultDecisionEnabled *bool `json:"defaultDecisionEnabled,omitempty"` + // JustificationRequiredOnApproval - Flag to indicate whether the reviewer is required to pass justification when recording a decision. + JustificationRequiredOnApproval *bool `json:"justificationRequiredOnApproval,omitempty"` + // DefaultDecision - This specifies the behavior for the autoReview feature when an access review completes. Possible values include: 'DefaultDecisionTypeApprove', 'DefaultDecisionTypeDeny', 'DefaultDecisionTypeRecommendation' + DefaultDecision DefaultDecisionType `json:"defaultDecision,omitempty"` + // AutoApplyDecisionsEnabled - Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. + AutoApplyDecisionsEnabled *bool `json:"autoApplyDecisionsEnabled,omitempty"` + // RecommendationsEnabled - Flag to indicate whether showing recommendations to reviewers is enabled. + RecommendationsEnabled *bool `json:"recommendationsEnabled,omitempty"` + // InstanceDurationInDays - The duration in days for an instance. + InstanceDurationInDays *int32 `json:"instanceDurationInDays,omitempty"` + // AccessReviewRecurrenceSettings - Access Review Settings. + *AccessReviewRecurrenceSettings `json:"recurrence,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccessReviewScheduleSettings. +func (arss AccessReviewScheduleSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if arss.MailNotificationsEnabled != nil { + objectMap["mailNotificationsEnabled"] = arss.MailNotificationsEnabled + } + if arss.ReminderNotificationsEnabled != nil { + objectMap["reminderNotificationsEnabled"] = arss.ReminderNotificationsEnabled + } + if arss.DefaultDecisionEnabled != nil { + objectMap["defaultDecisionEnabled"] = arss.DefaultDecisionEnabled + } + if arss.JustificationRequiredOnApproval != nil { + objectMap["justificationRequiredOnApproval"] = arss.JustificationRequiredOnApproval + } + if arss.DefaultDecision != "" { + objectMap["defaultDecision"] = arss.DefaultDecision + } + if arss.AutoApplyDecisionsEnabled != nil { + objectMap["autoApplyDecisionsEnabled"] = arss.AutoApplyDecisionsEnabled + } + if arss.RecommendationsEnabled != nil { + objectMap["recommendationsEnabled"] = arss.RecommendationsEnabled + } + if arss.InstanceDurationInDays != nil { + objectMap["instanceDurationInDays"] = arss.InstanceDurationInDays + } + if arss.AccessReviewRecurrenceSettings != nil { + objectMap["recurrence"] = arss.AccessReviewRecurrenceSettings + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AccessReviewScheduleSettings struct. +func (arss *AccessReviewScheduleSettings) 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 "mailNotificationsEnabled": + if v != nil { + var mailNotificationsEnabled bool + err = json.Unmarshal(*v, &mailNotificationsEnabled) + if err != nil { + return err + } + arss.MailNotificationsEnabled = &mailNotificationsEnabled + } + case "reminderNotificationsEnabled": + if v != nil { + var reminderNotificationsEnabled bool + err = json.Unmarshal(*v, &reminderNotificationsEnabled) + if err != nil { + return err + } + arss.ReminderNotificationsEnabled = &reminderNotificationsEnabled + } + case "defaultDecisionEnabled": + if v != nil { + var defaultDecisionEnabled bool + err = json.Unmarshal(*v, &defaultDecisionEnabled) + if err != nil { + return err + } + arss.DefaultDecisionEnabled = &defaultDecisionEnabled + } + case "justificationRequiredOnApproval": + if v != nil { + var justificationRequiredOnApproval bool + err = json.Unmarshal(*v, &justificationRequiredOnApproval) + if err != nil { + return err + } + arss.JustificationRequiredOnApproval = &justificationRequiredOnApproval + } + case "defaultDecision": + if v != nil { + var defaultDecision DefaultDecisionType + err = json.Unmarshal(*v, &defaultDecision) + if err != nil { + return err + } + arss.DefaultDecision = defaultDecision + } + case "autoApplyDecisionsEnabled": + if v != nil { + var autoApplyDecisionsEnabled bool + err = json.Unmarshal(*v, &autoApplyDecisionsEnabled) + if err != nil { + return err + } + arss.AutoApplyDecisionsEnabled = &autoApplyDecisionsEnabled + } + case "recommendationsEnabled": + if v != nil { + var recommendationsEnabled bool + err = json.Unmarshal(*v, &recommendationsEnabled) + if err != nil { + return err + } + arss.RecommendationsEnabled = &recommendationsEnabled + } + case "instanceDurationInDays": + if v != nil { + var instanceDurationInDays int32 + err = json.Unmarshal(*v, &instanceDurationInDays) + if err != nil { + return err + } + arss.InstanceDurationInDays = &instanceDurationInDays + } + case "recurrence": + if v != nil { + var accessReviewRecurrenceSettings AccessReviewRecurrenceSettings + err = json.Unmarshal(*v, &accessReviewRecurrenceSettings) + if err != nil { + return err + } + arss.AccessReviewRecurrenceSettings = &accessReviewRecurrenceSettings + } + } + } + + return nil +} + +// AccessReviewScope descriptor for what needs to be reviewed +type AccessReviewScope struct { + // ResourceID - READ-ONLY; ResourceId in which this review is getting created + ResourceID *string `json:"resourceId,omitempty"` + // RoleDefinitionID - READ-ONLY; This is used to indicate the role being reviewed + RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` + // PrincipalType - READ-ONLY; The identity type user/servicePrincipal to review. Possible values include: 'AccessReviewScopePrincipalTypeUser', 'AccessReviewScopePrincipalTypeServicePrincipal' + PrincipalType AccessReviewScopePrincipalType `json:"principalType,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccessReviewScope. +func (ars AccessReviewScope) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ApprovalSettings the approval settings. +type ApprovalSettings struct { + // IsApprovalRequired - Determine whether approval is required or not. + IsApprovalRequired *bool `json:"isApprovalRequired,omitempty"` + // IsApprovalRequiredForExtension - Determine whether approval is required for assignment extension. + IsApprovalRequiredForExtension *bool `json:"isApprovalRequiredForExtension,omitempty"` + // IsRequestorJustificationRequired - Determine whether requestor justification required. + IsRequestorJustificationRequired *bool `json:"isRequestorJustificationRequired,omitempty"` + // ApprovalMode - The type of rule. Possible values include: 'SingleStage', 'Serial', 'Parallel', 'NoApproval' + ApprovalMode ApprovalMode `json:"approvalMode,omitempty"` + // ApprovalStages - The approval stages of the request. + ApprovalStages *[]ApprovalStage `json:"approvalStages,omitempty"` +} + +// ApprovalStage the approval stage. +type ApprovalStage struct { + // ApprovalStageTimeOutInDays - The time in days when approval request would be timed out. + ApprovalStageTimeOutInDays *int32 `json:"approvalStageTimeOutInDays,omitempty"` + // IsApproverJustificationRequired - Determine whether approver need to provide justification for his decision. + IsApproverJustificationRequired *bool `json:"isApproverJustificationRequired,omitempty"` + // EscalationTimeInMinutes - The time in minutes when the approval request would be escalated if the primary approver does not approves. + EscalationTimeInMinutes *int32 `json:"escalationTimeInMinutes,omitempty"` + // PrimaryApprovers - The primary approver of the request. + PrimaryApprovers *[]UserSet `json:"primaryApprovers,omitempty"` + // IsEscalationEnabled - The value determine whether escalation feature is enabled. + IsEscalationEnabled *bool `json:"isEscalationEnabled,omitempty"` + // EscalationApprovers - The escalation approver of the request. + EscalationApprovers *[]UserSet `json:"escalationApprovers,omitempty"` +} + +// CloudError an error response from the service. +type CloudError struct { + Error *CloudErrorBody `json:"error,omitempty"` +} + +// CloudErrorBody an error response from the service. +type CloudErrorBody struct { + // Code - An identifier for the error. Codes are invariant and are intended to be consumed programmatically. + Code *string `json:"code,omitempty"` + // Message - A message describing the error, intended to be suitable for display in a user interface. + Message *string `json:"message,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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dalr DenyAssignmentListResult) hasNextLink() bool { + return dalr.NextLink != nil && len(*dalr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.dalr) + if err != nil { + return err + } + page.dalr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur DenyAssignmentListResult, getNextPage func(context.Context, DenyAssignmentListResult) (DenyAssignmentListResult, error)) DenyAssignmentListResultPage { + return DenyAssignmentListResultPage{ + fn: getNextPage, + dalr: cur, + } +} + +// 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"` +} + +// EligibleChildResource eligible child resource +type EligibleChildResource struct { + // ID - READ-ONLY; The resource scope Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for EligibleChildResource. +func (ecr EligibleChildResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// EligibleChildResourcesListResult eligible child resources list operation result. +type EligibleChildResourcesListResult struct { + autorest.Response `json:"-"` + // Value - Eligible child resource list. + Value *[]EligibleChildResource `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// EligibleChildResourcesListResultIterator provides access to a complete listing of EligibleChildResource +// values. +type EligibleChildResourcesListResultIterator struct { + i int + page EligibleChildResourcesListResultPage +} + +// 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 *EligibleChildResourcesListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EligibleChildResourcesListResultIterator.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 *EligibleChildResourcesListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter EligibleChildResourcesListResultIterator) 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 EligibleChildResourcesListResultIterator) Response() EligibleChildResourcesListResult { + 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 EligibleChildResourcesListResultIterator) Value() EligibleChildResource { + if !iter.page.NotDone() { + return EligibleChildResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the EligibleChildResourcesListResultIterator type. +func NewEligibleChildResourcesListResultIterator(page EligibleChildResourcesListResultPage) EligibleChildResourcesListResultIterator { + return EligibleChildResourcesListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ecrlr EligibleChildResourcesListResult) IsEmpty() bool { + return ecrlr.Value == nil || len(*ecrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ecrlr EligibleChildResourcesListResult) hasNextLink() bool { + return ecrlr.NextLink != nil && len(*ecrlr.NextLink) != 0 +} + +// eligibleChildResourcesListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ecrlr EligibleChildResourcesListResult) eligibleChildResourcesListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ecrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ecrlr.NextLink))) +} + +// EligibleChildResourcesListResultPage contains a page of EligibleChildResource values. +type EligibleChildResourcesListResultPage struct { + fn func(context.Context, EligibleChildResourcesListResult) (EligibleChildResourcesListResult, error) + ecrlr EligibleChildResourcesListResult +} + +// 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 *EligibleChildResourcesListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EligibleChildResourcesListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ecrlr) + if err != nil { + return err + } + page.ecrlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *EligibleChildResourcesListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page EligibleChildResourcesListResultPage) NotDone() bool { + return !page.ecrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page EligibleChildResourcesListResultPage) Response() EligibleChildResourcesListResult { + return page.ecrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page EligibleChildResourcesListResultPage) Values() []EligibleChildResource { + if page.ecrlr.IsEmpty() { + return nil + } + return *page.ecrlr.Value +} + +// Creates a new instance of the EligibleChildResourcesListResultPage type. +func NewEligibleChildResourcesListResultPage(cur EligibleChildResourcesListResult, getNextPage func(context.Context, EligibleChildResourcesListResult) (EligibleChildResourcesListResult, error)) EligibleChildResourcesListResultPage { + return EligibleChildResourcesListResultPage{ + fn: getNextPage, + ecrlr: cur, + } +} + +// ErrorAdditionalInfo the resource management error additional info. +type ErrorAdditionalInfo struct { + // Type - READ-ONLY; The additional info type. + Type *string `json:"type,omitempty"` + // Info - READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorAdditionalInfo. +func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorDefinition error description and code explaining why an operation failed. +type ErrorDefinition struct { + // Error - Error of the list gateway status. + Error *ErrorDefinitionProperties `json:"error,omitempty"` +} + +// ErrorDefinitionProperties error description and code explaining why an operation failed. +type ErrorDefinitionProperties struct { + // Message - READ-ONLY; Description of the error. + Message *string `json:"message,omitempty"` + // Code - Error code of list gateway. + Code *string `json:"code,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDefinitionProperties. +func (edp ErrorDefinitionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if edp.Code != nil { + objectMap["code"] = edp.Code + } + return json.Marshal(objectMap) +} + +// ErrorDetail the error detail. +type ErrorDetail struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The error target. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; The error details. + Details *[]ErrorDetail `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDetail. +func (ed ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorResponse common error response for all Azure Resource Manager APIs to return error details for +// failed operations. (This also follows the OData error response format.). +type ErrorResponse struct { + // Error - The error object. + Error *ErrorDetail `json:"error,omitempty"` +} + +// ExpandedProperties ... +type ExpandedProperties struct { + // Scope - Details of the resource scope + Scope *ExpandedPropertiesScope `json:"scope,omitempty"` + // RoleDefinition - Details of role definition + RoleDefinition *ExpandedPropertiesRoleDefinition `json:"roleDefinition,omitempty"` + // Principal - Details of the principal + Principal *ExpandedPropertiesPrincipal `json:"principal,omitempty"` +} + +// ExpandedPropertiesPrincipal details of the principal +type ExpandedPropertiesPrincipal struct { + // ID - Id of the principal + ID *string `json:"id,omitempty"` + // DisplayName - Display name of the principal + DisplayName *string `json:"displayName,omitempty"` + // Email - Email id of the principal + Email *string `json:"email,omitempty"` + // Type - Type of the principal + Type *string `json:"type,omitempty"` +} + +// ExpandedPropertiesRoleDefinition details of role definition +type ExpandedPropertiesRoleDefinition struct { + // ID - Id of the role definition + ID *string `json:"id,omitempty"` + // DisplayName - Display name of the role definition + DisplayName *string `json:"displayName,omitempty"` + // Type - Type of the role definition + Type *string `json:"type,omitempty"` +} + +// ExpandedPropertiesScope details of the resource scope +type ExpandedPropertiesScope struct { + // ID - Scope id of the resource + ID *string `json:"id,omitempty"` + // DisplayName - Display name of the resource + DisplayName *string `json:"displayName,omitempty"` + // Type - Type of the resource + Type *string `json:"type,omitempty"` +} + +// Operation the definition of a Microsoft.Authorization operation. +type Operation struct { + // Name - Name of the operation + Name *string `json:"name,omitempty"` + // IsDataAction - Indicates whether the operation is a data action + IsDataAction *bool `json:"isDataAction,omitempty"` + // Display - Display of the operation + Display *OperationDisplay `json:"display,omitempty"` + // Origin - Origin of the operation + Origin *string `json:"origin,omitempty"` +} + +// OperationDisplay the display information for a Microsoft.Authorization operation. +type OperationDisplay struct { + // Provider - READ-ONLY; The resource provider name: Microsoft.Authorization. + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; The resource on which the operation is performed. + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; The operation that users can perform. + Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; The description for the operation. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationDisplay. +func (od OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationListResult the result of a request to list Microsoft.Authorization operations. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - The collection value. + Value *[]Operation `json:"value,omitempty"` + // NextLink - The URI that can be used to request the next set of paged results. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListResultIterator) Response() OperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !olr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{ + fn: getNextPage, + olr: cur, + } +} + +// 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (pgr PermissionGetResult) hasNextLink() bool { + return pgr.NextLink != nil && len(*pgr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.pgr) + if err != nil { + return err + } + page.pgr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur PermissionGetResult, getNextPage func(context.Context, PermissionGetResult) (PermissionGetResult, error)) PermissionGetResultPage { + return PermissionGetResultPage{ + fn: getNextPage, + pgr: cur, + } +} + +// PolicyAssignmentProperties ... +type PolicyAssignmentProperties struct { + // Scope - Details of the resource scope + Scope *PolicyAssignmentPropertiesScope `json:"scope,omitempty"` + // RoleDefinition - Details of role definition + RoleDefinition *PolicyAssignmentPropertiesRoleDefinition `json:"roleDefinition,omitempty"` + // Policy - Details of the policy + Policy *PolicyAssignmentPropertiesPolicy `json:"policy,omitempty"` +} + +// PolicyAssignmentPropertiesPolicy details of the policy +type PolicyAssignmentPropertiesPolicy struct { + // ID - Id of the policy + ID *string `json:"id,omitempty"` + LastModifiedBy *Principal `json:"lastModifiedBy,omitempty"` + // LastModifiedDateTime - The last modified date time. + LastModifiedDateTime *date.Time `json:"lastModifiedDateTime,omitempty"` +} + +// PolicyAssignmentPropertiesRoleDefinition details of role definition +type PolicyAssignmentPropertiesRoleDefinition struct { + // ID - Id of the role definition + ID *string `json:"id,omitempty"` + // DisplayName - Display name of the role definition + DisplayName *string `json:"displayName,omitempty"` + // Type - Type of the role definition + Type *string `json:"type,omitempty"` +} + +// PolicyAssignmentPropertiesScope details of the resource scope +type PolicyAssignmentPropertiesScope struct { + // ID - Scope id of the resource + ID *string `json:"id,omitempty"` + // DisplayName - Display name of the resource + DisplayName *string `json:"displayName,omitempty"` + // Type - Type of the resource + Type *string `json:"type,omitempty"` +} + +// PolicyProperties ... +type PolicyProperties struct { + // Scope - READ-ONLY; Details of the resource scope + Scope *PolicyPropertiesScope `json:"scope,omitempty"` +} + +// MarshalJSON is the custom marshaler for PolicyProperties. +func (pp PolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PolicyPropertiesScope details of the resource scope +type PolicyPropertiesScope struct { + // ID - Scope id of the resource + ID *string `json:"id,omitempty"` + // DisplayName - Display name of the resource + DisplayName *string `json:"displayName,omitempty"` + // Type - Type of the resource + Type *string `json:"type,omitempty"` +} + +// Principal the name of the entity last modified it +type Principal struct { + // ID - The id of the principal made changes + ID *string `json:"id,omitempty"` + // DisplayName - The name of the principal made changes + DisplayName *string `json:"displayName,omitempty"` + // Type - Type of principal such as user , group etc + Type *string `json:"type,omitempty"` + // Email - Email of principal + Email *string `json:"email,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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (pomlr ProviderOperationsMetadataListResult) hasNextLink() bool { + return pomlr.NextLink != nil && len(*pomlr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.pomlr) + if err != nil { + return err + } + page.pomlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur ProviderOperationsMetadataListResult, getNextPage func(context.Context, ProviderOperationsMetadataListResult) (ProviderOperationsMetadataListResult, error)) ProviderOperationsMetadataListResultPage { + return ProviderOperationsMetadataListResultPage{ + fn: getNextPage, + pomlr: cur, + } +} + +// 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"` + // RoleAssignmentProperties - Role assignment properties. + *RoleAssignmentProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleAssignment. +func (ra RoleAssignment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ra.RoleAssignmentProperties != nil { + objectMap["properties"] = ra.RoleAssignmentProperties + } + 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 roleAssignmentProperties RoleAssignmentProperties + err = json.Unmarshal(*v, &roleAssignmentProperties) + if err != nil { + return err + } + ra.RoleAssignmentProperties = &roleAssignmentProperties + } + } + } + + 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"` +} + +// RoleAssignmentListResult role assignment list operation result. +type RoleAssignmentListResult struct { + autorest.Response `json:"-"` + // Value - Role assignment list. + Value *[]RoleAssignment `json:"value,omitempty"` + // NextLink - READ-ONLY; The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleAssignmentListResult. +func (ralr RoleAssignmentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ralr.Value != nil { + objectMap["value"] = ralr.Value + } + return json.Marshal(objectMap) +} + +// 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ralr RoleAssignmentListResult) hasNextLink() bool { + return ralr.NextLink != nil && len(*ralr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.ralr) + if err != nil { + return err + } + page.ralr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur RoleAssignmentListResult, getNextPage func(context.Context, RoleAssignmentListResult) (RoleAssignmentListResult, error)) RoleAssignmentListResultPage { + return RoleAssignmentListResultPage{ + fn: getNextPage, + ralr: cur, + } +} + +// RoleAssignmentMetricsResult role Assignment Metrics +type RoleAssignmentMetricsResult struct { + autorest.Response `json:"-"` + // SubscriptionID - READ-ONLY; The subscription ID. + SubscriptionID *string `json:"subscriptionId,omitempty"` + // RoleAssignmentsLimit - READ-ONLY; The role assignment limit. + RoleAssignmentsLimit *int64 `json:"roleAssignmentsLimit,omitempty"` + // RoleAssignmentsCurrentCount - READ-ONLY; The number of current role assignments. + RoleAssignmentsCurrentCount *int64 `json:"roleAssignmentsCurrentCount,omitempty"` + // RoleAssignmentsRemainingCount - READ-ONLY; The number of remaining role assignments available. + RoleAssignmentsRemainingCount *int64 `json:"roleAssignmentsRemainingCount,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleAssignmentMetricsResult. +func (ramr RoleAssignmentMetricsResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RoleAssignmentProperties role assignment properties. +type RoleAssignmentProperties struct { + // Scope - READ-ONLY; 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: 'PrincipalTypeUser', 'PrincipalTypeGroup', 'PrincipalTypeServicePrincipal', 'PrincipalTypeForeignGroup', 'PrincipalTypeDevice' + PrincipalType PrincipalType `json:"principalType,omitempty"` + // Description - Description of role assignment + Description *string `json:"description,omitempty"` + // Condition - The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container' + Condition *string `json:"condition,omitempty"` + // ConditionVersion - Version of the condition. Currently accepted value is '2.0' + ConditionVersion *string `json:"conditionVersion,omitempty"` + // CreatedOn - READ-ONLY; Time it was created + CreatedOn *date.Time `json:"createdOn,omitempty"` + // UpdatedOn - READ-ONLY; Time it was updated + UpdatedOn *date.Time `json:"updatedOn,omitempty"` + // CreatedBy - READ-ONLY; Id of the user who created the assignment + CreatedBy *string `json:"createdBy,omitempty"` + // UpdatedBy - READ-ONLY; Id of the user who updated the assignment + UpdatedBy *string `json:"updatedBy,omitempty"` + // DelegatedManagedIdentityResourceID - Id of the delegated managed identity resource + DelegatedManagedIdentityResourceID *string `json:"delegatedManagedIdentityResourceId,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleAssignmentProperties. +func (rap RoleAssignmentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rap.RoleDefinitionID != nil { + objectMap["roleDefinitionId"] = rap.RoleDefinitionID + } + if rap.PrincipalID != nil { + objectMap["principalId"] = rap.PrincipalID + } + if rap.PrincipalType != "" { + objectMap["principalType"] = rap.PrincipalType + } + if rap.Description != nil { + objectMap["description"] = rap.Description + } + if rap.Condition != nil { + objectMap["condition"] = rap.Condition + } + if rap.ConditionVersion != nil { + objectMap["conditionVersion"] = rap.ConditionVersion + } + if rap.DelegatedManagedIdentityResourceID != nil { + objectMap["delegatedManagedIdentityResourceId"] = rap.DelegatedManagedIdentityResourceID + } + return json.Marshal(objectMap) +} + +// RoleAssignmentSchedule role Assignment schedule +type RoleAssignmentSchedule struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The role assignment schedule Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The role assignment schedule name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The role assignment schedule type. + Type *string `json:"type,omitempty"` + // RoleAssignmentScheduleProperties - Role assignment schedule properties. + *RoleAssignmentScheduleProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleAssignmentSchedule. +func (ras RoleAssignmentSchedule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ras.RoleAssignmentScheduleProperties != nil { + objectMap["properties"] = ras.RoleAssignmentScheduleProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RoleAssignmentSchedule struct. +func (ras *RoleAssignmentSchedule) 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 + } + ras.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ras.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ras.Type = &typeVar + } + case "properties": + if v != nil { + var roleAssignmentScheduleProperties RoleAssignmentScheduleProperties + err = json.Unmarshal(*v, &roleAssignmentScheduleProperties) + if err != nil { + return err + } + ras.RoleAssignmentScheduleProperties = &roleAssignmentScheduleProperties + } + } + } + + return nil +} + +// RoleAssignmentScheduleFilter role assignment schedule filter +type RoleAssignmentScheduleFilter struct { + // PrincipalID - Returns role assignment schedule of the specific principal. + PrincipalID *string `json:"principalId,omitempty"` + // RoleDefinitionID - Returns role assignment schedule of the specific role definition. + RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` + // Status - Returns role assignment schedule instances of the specific status. + Status *string `json:"status,omitempty"` +} + +// RoleAssignmentScheduleInstance information about current or upcoming role assignment schedule instance +type RoleAssignmentScheduleInstance struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The role assignment schedule instance ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The role assignment schedule instance name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The role assignment schedule instance type. + Type *string `json:"type,omitempty"` + // RoleAssignmentScheduleInstanceProperties - Role assignment schedule instance properties. + *RoleAssignmentScheduleInstanceProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleAssignmentScheduleInstance. +func (rasi RoleAssignmentScheduleInstance) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rasi.RoleAssignmentScheduleInstanceProperties != nil { + objectMap["properties"] = rasi.RoleAssignmentScheduleInstanceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RoleAssignmentScheduleInstance struct. +func (rasi *RoleAssignmentScheduleInstance) 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 + } + rasi.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rasi.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rasi.Type = &typeVar + } + case "properties": + if v != nil { + var roleAssignmentScheduleInstanceProperties RoleAssignmentScheduleInstanceProperties + err = json.Unmarshal(*v, &roleAssignmentScheduleInstanceProperties) + if err != nil { + return err + } + rasi.RoleAssignmentScheduleInstanceProperties = &roleAssignmentScheduleInstanceProperties + } + } + } + + return nil +} + +// RoleAssignmentScheduleInstanceFilter role assignment schedule instance filter +type RoleAssignmentScheduleInstanceFilter struct { + // PrincipalID - Returns role assignment schedule instances of the specific principal. + PrincipalID *string `json:"principalId,omitempty"` + // RoleDefinitionID - Returns role assignment schedule instances of the specific role definition. + RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` + // Status - Returns role assignment schedule instances of the specific status. + Status *string `json:"status,omitempty"` + // RoleAssignmentScheduleID - Returns role assignment schedule instances belonging to a specific role assignment schedule. + RoleAssignmentScheduleID *string `json:"roleAssignmentScheduleId,omitempty"` +} + +// RoleAssignmentScheduleInstanceListResult role assignment schedule instance list operation result. +type RoleAssignmentScheduleInstanceListResult struct { + autorest.Response `json:"-"` + // Value - Role assignment schedule instance list. + Value *[]RoleAssignmentScheduleInstance `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// RoleAssignmentScheduleInstanceListResultIterator provides access to a complete listing of +// RoleAssignmentScheduleInstance values. +type RoleAssignmentScheduleInstanceListResultIterator struct { + i int + page RoleAssignmentScheduleInstanceListResultPage +} + +// 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 *RoleAssignmentScheduleInstanceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentScheduleInstanceListResultIterator.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 *RoleAssignmentScheduleInstanceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RoleAssignmentScheduleInstanceListResultIterator) 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 RoleAssignmentScheduleInstanceListResultIterator) Response() RoleAssignmentScheduleInstanceListResult { + 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 RoleAssignmentScheduleInstanceListResultIterator) Value() RoleAssignmentScheduleInstance { + if !iter.page.NotDone() { + return RoleAssignmentScheduleInstance{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RoleAssignmentScheduleInstanceListResultIterator type. +func NewRoleAssignmentScheduleInstanceListResultIterator(page RoleAssignmentScheduleInstanceListResultPage) RoleAssignmentScheduleInstanceListResultIterator { + return RoleAssignmentScheduleInstanceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rasilr RoleAssignmentScheduleInstanceListResult) IsEmpty() bool { + return rasilr.Value == nil || len(*rasilr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rasilr RoleAssignmentScheduleInstanceListResult) hasNextLink() bool { + return rasilr.NextLink != nil && len(*rasilr.NextLink) != 0 +} + +// roleAssignmentScheduleInstanceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rasilr RoleAssignmentScheduleInstanceListResult) roleAssignmentScheduleInstanceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !rasilr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rasilr.NextLink))) +} + +// RoleAssignmentScheduleInstanceListResultPage contains a page of RoleAssignmentScheduleInstance values. +type RoleAssignmentScheduleInstanceListResultPage struct { + fn func(context.Context, RoleAssignmentScheduleInstanceListResult) (RoleAssignmentScheduleInstanceListResult, error) + rasilr RoleAssignmentScheduleInstanceListResult +} + +// 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 *RoleAssignmentScheduleInstanceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentScheduleInstanceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rasilr) + if err != nil { + return err + } + page.rasilr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RoleAssignmentScheduleInstanceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RoleAssignmentScheduleInstanceListResultPage) NotDone() bool { + return !page.rasilr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RoleAssignmentScheduleInstanceListResultPage) Response() RoleAssignmentScheduleInstanceListResult { + return page.rasilr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RoleAssignmentScheduleInstanceListResultPage) Values() []RoleAssignmentScheduleInstance { + if page.rasilr.IsEmpty() { + return nil + } + return *page.rasilr.Value +} + +// Creates a new instance of the RoleAssignmentScheduleInstanceListResultPage type. +func NewRoleAssignmentScheduleInstanceListResultPage(cur RoleAssignmentScheduleInstanceListResult, getNextPage func(context.Context, RoleAssignmentScheduleInstanceListResult) (RoleAssignmentScheduleInstanceListResult, error)) RoleAssignmentScheduleInstanceListResultPage { + return RoleAssignmentScheduleInstanceListResultPage{ + fn: getNextPage, + rasilr: cur, + } +} + +// RoleAssignmentScheduleInstanceProperties role assignment schedule properties with scope. +type RoleAssignmentScheduleInstanceProperties struct { + // Scope - The role assignment schedule 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: 'PrincipalTypeUser', 'PrincipalTypeGroup', 'PrincipalTypeServicePrincipal', 'PrincipalTypeForeignGroup', 'PrincipalTypeDevice' + PrincipalType PrincipalType `json:"principalType,omitempty"` + // RoleAssignmentScheduleID - Id of the master role assignment schedule + RoleAssignmentScheduleID *string `json:"roleAssignmentScheduleId,omitempty"` + // OriginRoleAssignmentID - Role Assignment Id in external system + OriginRoleAssignmentID *string `json:"originRoleAssignmentId,omitempty"` + // Status - The status of the role assignment schedule instance. Possible values include: 'Accepted', 'PendingEvaluation', 'Granted', 'Denied', 'PendingProvisioning', 'Provisioned', 'PendingRevocation', 'Revoked', 'Canceled', 'Failed', 'PendingApprovalProvisioning', 'PendingApproval', 'FailedAsResourceIsLocked', 'PendingAdminDecision', 'AdminApproved', 'AdminDenied', 'TimedOut', 'ProvisioningStarted', 'Invalid', 'PendingScheduleCreation', 'ScheduleCreated', 'PendingExternalProvisioning' + Status Status `json:"status,omitempty"` + // StartDateTime - The startDateTime of the role assignment schedule instance + StartDateTime *date.Time `json:"startDateTime,omitempty"` + // EndDateTime - The endDateTime of the role assignment schedule instance + EndDateTime *date.Time `json:"endDateTime,omitempty"` + // LinkedRoleEligibilityScheduleID - roleEligibilityScheduleId used to activate + LinkedRoleEligibilityScheduleID *string `json:"linkedRoleEligibilityScheduleId,omitempty"` + // LinkedRoleEligibilityScheduleInstanceID - roleEligibilityScheduleInstanceId linked to this roleAssignmentScheduleInstance + LinkedRoleEligibilityScheduleInstanceID *string `json:"linkedRoleEligibilityScheduleInstanceId,omitempty"` + // AssignmentType - Assignment type of the role assignment schedule. Possible values include: 'AssignmentTypeActivated', 'AssignmentTypeAssigned' + AssignmentType AssignmentType `json:"assignmentType,omitempty"` + // MemberType - Membership type of the role assignment schedule. Possible values include: 'Inherited', 'Direct', 'Group' + MemberType MemberType `json:"memberType,omitempty"` + // Condition - The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container' + Condition *string `json:"condition,omitempty"` + // ConditionVersion - Version of the condition. Currently accepted value is '2.0' + ConditionVersion *string `json:"conditionVersion,omitempty"` + // CreatedOn - DateTime when role assignment schedule was created + CreatedOn *date.Time `json:"createdOn,omitempty"` + // ExpandedProperties - Additional properties of principal, scope and role definition + ExpandedProperties *ExpandedProperties `json:"expandedProperties,omitempty"` +} + +// RoleAssignmentScheduleListResult role assignment schedule list operation result. +type RoleAssignmentScheduleListResult struct { + autorest.Response `json:"-"` + // Value - Role assignment schedule list. + Value *[]RoleAssignmentSchedule `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// RoleAssignmentScheduleListResultIterator provides access to a complete listing of RoleAssignmentSchedule +// values. +type RoleAssignmentScheduleListResultIterator struct { + i int + page RoleAssignmentScheduleListResultPage +} + +// 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 *RoleAssignmentScheduleListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentScheduleListResultIterator.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 *RoleAssignmentScheduleListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RoleAssignmentScheduleListResultIterator) 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 RoleAssignmentScheduleListResultIterator) Response() RoleAssignmentScheduleListResult { + 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 RoleAssignmentScheduleListResultIterator) Value() RoleAssignmentSchedule { + if !iter.page.NotDone() { + return RoleAssignmentSchedule{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RoleAssignmentScheduleListResultIterator type. +func NewRoleAssignmentScheduleListResultIterator(page RoleAssignmentScheduleListResultPage) RoleAssignmentScheduleListResultIterator { + return RoleAssignmentScheduleListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (raslr RoleAssignmentScheduleListResult) IsEmpty() bool { + return raslr.Value == nil || len(*raslr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (raslr RoleAssignmentScheduleListResult) hasNextLink() bool { + return raslr.NextLink != nil && len(*raslr.NextLink) != 0 +} + +// roleAssignmentScheduleListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (raslr RoleAssignmentScheduleListResult) roleAssignmentScheduleListResultPreparer(ctx context.Context) (*http.Request, error) { + if !raslr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(raslr.NextLink))) +} + +// RoleAssignmentScheduleListResultPage contains a page of RoleAssignmentSchedule values. +type RoleAssignmentScheduleListResultPage struct { + fn func(context.Context, RoleAssignmentScheduleListResult) (RoleAssignmentScheduleListResult, error) + raslr RoleAssignmentScheduleListResult +} + +// 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 *RoleAssignmentScheduleListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentScheduleListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.raslr) + if err != nil { + return err + } + page.raslr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RoleAssignmentScheduleListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RoleAssignmentScheduleListResultPage) NotDone() bool { + return !page.raslr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RoleAssignmentScheduleListResultPage) Response() RoleAssignmentScheduleListResult { + return page.raslr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RoleAssignmentScheduleListResultPage) Values() []RoleAssignmentSchedule { + if page.raslr.IsEmpty() { + return nil + } + return *page.raslr.Value +} + +// Creates a new instance of the RoleAssignmentScheduleListResultPage type. +func NewRoleAssignmentScheduleListResultPage(cur RoleAssignmentScheduleListResult, getNextPage func(context.Context, RoleAssignmentScheduleListResult) (RoleAssignmentScheduleListResult, error)) RoleAssignmentScheduleListResultPage { + return RoleAssignmentScheduleListResultPage{ + fn: getNextPage, + raslr: cur, + } +} + +// RoleAssignmentScheduleProperties role assignment schedule properties with scope. +type RoleAssignmentScheduleProperties struct { + // Scope - The role assignment schedule 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: 'PrincipalTypeUser', 'PrincipalTypeGroup', 'PrincipalTypeServicePrincipal', 'PrincipalTypeForeignGroup', 'PrincipalTypeDevice' + PrincipalType PrincipalType `json:"principalType,omitempty"` + // RoleAssignmentScheduleRequestID - The id of roleAssignmentScheduleRequest used to create this roleAssignmentSchedule + RoleAssignmentScheduleRequestID *string `json:"roleAssignmentScheduleRequestId,omitempty"` + // LinkedRoleEligibilityScheduleID - The id of roleEligibilitySchedule used to activated this roleAssignmentSchedule + LinkedRoleEligibilityScheduleID *string `json:"linkedRoleEligibilityScheduleId,omitempty"` + // AssignmentType - Assignment type of the role assignment schedule. Possible values include: 'AssignmentTypeActivated', 'AssignmentTypeAssigned' + AssignmentType AssignmentType `json:"assignmentType,omitempty"` + // MemberType - Membership type of the role assignment schedule. Possible values include: 'Inherited', 'Direct', 'Group' + MemberType MemberType `json:"memberType,omitempty"` + // Status - The status of the role assignment schedule. Possible values include: 'Accepted', 'PendingEvaluation', 'Granted', 'Denied', 'PendingProvisioning', 'Provisioned', 'PendingRevocation', 'Revoked', 'Canceled', 'Failed', 'PendingApprovalProvisioning', 'PendingApproval', 'FailedAsResourceIsLocked', 'PendingAdminDecision', 'AdminApproved', 'AdminDenied', 'TimedOut', 'ProvisioningStarted', 'Invalid', 'PendingScheduleCreation', 'ScheduleCreated', 'PendingExternalProvisioning' + Status Status `json:"status,omitempty"` + // StartDateTime - Start DateTime when role assignment schedule + StartDateTime *date.Time `json:"startDateTime,omitempty"` + // EndDateTime - End DateTime when role assignment schedule + EndDateTime *date.Time `json:"endDateTime,omitempty"` + // Condition - The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container' + Condition *string `json:"condition,omitempty"` + // ConditionVersion - Version of the condition. Currently accepted value is '2.0' + ConditionVersion *string `json:"conditionVersion,omitempty"` + // CreatedOn - DateTime when role assignment schedule was created + CreatedOn *date.Time `json:"createdOn,omitempty"` + // UpdatedOn - DateTime when role assignment schedule was modified + UpdatedOn *date.Time `json:"updatedOn,omitempty"` + // ExpandedProperties - Additional properties of principal, scope and role definition + ExpandedProperties *ExpandedProperties `json:"expandedProperties,omitempty"` +} + +// RoleAssignmentScheduleRequest role Assignment schedule request +type RoleAssignmentScheduleRequest struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The role assignment schedule request ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The role assignment schedule request name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The role assignment schedule request type. + Type *string `json:"type,omitempty"` + // RoleAssignmentScheduleRequestProperties - Role assignment schedule request properties. + *RoleAssignmentScheduleRequestProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleAssignmentScheduleRequest. +func (rasr RoleAssignmentScheduleRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rasr.RoleAssignmentScheduleRequestProperties != nil { + objectMap["properties"] = rasr.RoleAssignmentScheduleRequestProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RoleAssignmentScheduleRequest struct. +func (rasr *RoleAssignmentScheduleRequest) 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 + } + rasr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rasr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rasr.Type = &typeVar + } + case "properties": + if v != nil { + var roleAssignmentScheduleRequestProperties RoleAssignmentScheduleRequestProperties + err = json.Unmarshal(*v, &roleAssignmentScheduleRequestProperties) + if err != nil { + return err + } + rasr.RoleAssignmentScheduleRequestProperties = &roleAssignmentScheduleRequestProperties + } + } + } + + return nil +} + +// RoleAssignmentScheduleRequestFilter role assignment schedule request filter +type RoleAssignmentScheduleRequestFilter struct { + // PrincipalID - Returns role assignment requests of the specific principal. + PrincipalID *string `json:"principalId,omitempty"` + // RoleDefinitionID - Returns role assignment requests of the specific role definition. + RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` + // RequestorID - Returns role assignment requests created by specific principal. + RequestorID *string `json:"requestorId,omitempty"` + // Status - Returns role assignment requests of specific status. + Status *string `json:"status,omitempty"` +} + +// RoleAssignmentScheduleRequestListResult role assignment schedule request list operation result. +type RoleAssignmentScheduleRequestListResult struct { + autorest.Response `json:"-"` + // Value - Role assignment schedule request list. + Value *[]RoleAssignmentScheduleRequest `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// RoleAssignmentScheduleRequestListResultIterator provides access to a complete listing of +// RoleAssignmentScheduleRequest values. +type RoleAssignmentScheduleRequestListResultIterator struct { + i int + page RoleAssignmentScheduleRequestListResultPage +} + +// 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 *RoleAssignmentScheduleRequestListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentScheduleRequestListResultIterator.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 *RoleAssignmentScheduleRequestListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RoleAssignmentScheduleRequestListResultIterator) 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 RoleAssignmentScheduleRequestListResultIterator) Response() RoleAssignmentScheduleRequestListResult { + 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 RoleAssignmentScheduleRequestListResultIterator) Value() RoleAssignmentScheduleRequest { + if !iter.page.NotDone() { + return RoleAssignmentScheduleRequest{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RoleAssignmentScheduleRequestListResultIterator type. +func NewRoleAssignmentScheduleRequestListResultIterator(page RoleAssignmentScheduleRequestListResultPage) RoleAssignmentScheduleRequestListResultIterator { + return RoleAssignmentScheduleRequestListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rasrlr RoleAssignmentScheduleRequestListResult) IsEmpty() bool { + return rasrlr.Value == nil || len(*rasrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rasrlr RoleAssignmentScheduleRequestListResult) hasNextLink() bool { + return rasrlr.NextLink != nil && len(*rasrlr.NextLink) != 0 +} + +// roleAssignmentScheduleRequestListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rasrlr RoleAssignmentScheduleRequestListResult) roleAssignmentScheduleRequestListResultPreparer(ctx context.Context) (*http.Request, error) { + if !rasrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rasrlr.NextLink))) +} + +// RoleAssignmentScheduleRequestListResultPage contains a page of RoleAssignmentScheduleRequest values. +type RoleAssignmentScheduleRequestListResultPage struct { + fn func(context.Context, RoleAssignmentScheduleRequestListResult) (RoleAssignmentScheduleRequestListResult, error) + rasrlr RoleAssignmentScheduleRequestListResult +} + +// 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 *RoleAssignmentScheduleRequestListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentScheduleRequestListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rasrlr) + if err != nil { + return err + } + page.rasrlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RoleAssignmentScheduleRequestListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RoleAssignmentScheduleRequestListResultPage) NotDone() bool { + return !page.rasrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RoleAssignmentScheduleRequestListResultPage) Response() RoleAssignmentScheduleRequestListResult { + return page.rasrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RoleAssignmentScheduleRequestListResultPage) Values() []RoleAssignmentScheduleRequest { + if page.rasrlr.IsEmpty() { + return nil + } + return *page.rasrlr.Value +} + +// Creates a new instance of the RoleAssignmentScheduleRequestListResultPage type. +func NewRoleAssignmentScheduleRequestListResultPage(cur RoleAssignmentScheduleRequestListResult, getNextPage func(context.Context, RoleAssignmentScheduleRequestListResult) (RoleAssignmentScheduleRequestListResult, error)) RoleAssignmentScheduleRequestListResultPage { + return RoleAssignmentScheduleRequestListResultPage{ + fn: getNextPage, + rasrlr: cur, + } +} + +// RoleAssignmentScheduleRequestProperties role assignment schedule request properties with scope. +type RoleAssignmentScheduleRequestProperties struct { + // Scope - READ-ONLY; The role assignment schedule request 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 - READ-ONLY; The principal type of the assigned principal ID. Possible values include: 'PrincipalTypeUser', 'PrincipalTypeGroup', 'PrincipalTypeServicePrincipal', 'PrincipalTypeForeignGroup', 'PrincipalTypeDevice' + PrincipalType PrincipalType `json:"principalType,omitempty"` + // RequestType - The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc. Possible values include: 'AdminAssign', 'AdminRemove', 'AdminUpdate', 'AdminExtend', 'AdminRenew', 'SelfActivate', 'SelfDeactivate', 'SelfExtend', 'SelfRenew' + RequestType RequestType `json:"requestType,omitempty"` + // Status - READ-ONLY; The status of the role assignment schedule request. Possible values include: 'Accepted', 'PendingEvaluation', 'Granted', 'Denied', 'PendingProvisioning', 'Provisioned', 'PendingRevocation', 'Revoked', 'Canceled', 'Failed', 'PendingApprovalProvisioning', 'PendingApproval', 'FailedAsResourceIsLocked', 'PendingAdminDecision', 'AdminApproved', 'AdminDenied', 'TimedOut', 'ProvisioningStarted', 'Invalid', 'PendingScheduleCreation', 'ScheduleCreated', 'PendingExternalProvisioning' + Status Status `json:"status,omitempty"` + // ApprovalID - READ-ONLY; The approvalId of the role assignment schedule request. + ApprovalID *string `json:"approvalId,omitempty"` + // TargetRoleAssignmentScheduleID - The resultant role assignment schedule id or the role assignment schedule id being updated + TargetRoleAssignmentScheduleID *string `json:"targetRoleAssignmentScheduleId,omitempty"` + // TargetRoleAssignmentScheduleInstanceID - The role assignment schedule instance id being updated + TargetRoleAssignmentScheduleInstanceID *string `json:"targetRoleAssignmentScheduleInstanceId,omitempty"` + // ScheduleInfo - Schedule info of the role assignment schedule + ScheduleInfo *RoleAssignmentScheduleRequestPropertiesScheduleInfo `json:"scheduleInfo,omitempty"` + // LinkedRoleEligibilityScheduleID - The linked role eligibility schedule id - to activate an eligibility. + LinkedRoleEligibilityScheduleID *string `json:"linkedRoleEligibilityScheduleId,omitempty"` + // Justification - Justification for the role assignment + Justification *string `json:"justification,omitempty"` + // TicketInfo - Ticket Info of the role assignment + TicketInfo *RoleAssignmentScheduleRequestPropertiesTicketInfo `json:"ticketInfo,omitempty"` + // Condition - The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container' + Condition *string `json:"condition,omitempty"` + // ConditionVersion - Version of the condition. Currently accepted value is '2.0' + ConditionVersion *string `json:"conditionVersion,omitempty"` + // CreatedOn - READ-ONLY; DateTime when role assignment schedule request was created + CreatedOn *date.Time `json:"createdOn,omitempty"` + // RequestorID - READ-ONLY; Id of the user who created this request + RequestorID *string `json:"requestorId,omitempty"` + // ExpandedProperties - READ-ONLY; Additional properties of principal, scope and role definition + ExpandedProperties *ExpandedProperties `json:"expandedProperties,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleAssignmentScheduleRequestProperties. +func (rasrp RoleAssignmentScheduleRequestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rasrp.RoleDefinitionID != nil { + objectMap["roleDefinitionId"] = rasrp.RoleDefinitionID + } + if rasrp.PrincipalID != nil { + objectMap["principalId"] = rasrp.PrincipalID + } + if rasrp.RequestType != "" { + objectMap["requestType"] = rasrp.RequestType + } + if rasrp.TargetRoleAssignmentScheduleID != nil { + objectMap["targetRoleAssignmentScheduleId"] = rasrp.TargetRoleAssignmentScheduleID + } + if rasrp.TargetRoleAssignmentScheduleInstanceID != nil { + objectMap["targetRoleAssignmentScheduleInstanceId"] = rasrp.TargetRoleAssignmentScheduleInstanceID + } + if rasrp.ScheduleInfo != nil { + objectMap["scheduleInfo"] = rasrp.ScheduleInfo + } + if rasrp.LinkedRoleEligibilityScheduleID != nil { + objectMap["linkedRoleEligibilityScheduleId"] = rasrp.LinkedRoleEligibilityScheduleID + } + if rasrp.Justification != nil { + objectMap["justification"] = rasrp.Justification + } + if rasrp.TicketInfo != nil { + objectMap["ticketInfo"] = rasrp.TicketInfo + } + if rasrp.Condition != nil { + objectMap["condition"] = rasrp.Condition + } + if rasrp.ConditionVersion != nil { + objectMap["conditionVersion"] = rasrp.ConditionVersion + } + return json.Marshal(objectMap) +} + +// RoleAssignmentScheduleRequestPropertiesScheduleInfo schedule info of the role assignment schedule +type RoleAssignmentScheduleRequestPropertiesScheduleInfo struct { + // StartDateTime - Start DateTime of the role assignment schedule. + StartDateTime *date.Time `json:"startDateTime,omitempty"` + // Expiration - Expiration of the role assignment schedule + Expiration *RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration `json:"expiration,omitempty"` +} + +// RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration expiration of the role assignment schedule +type RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration struct { + // Type - Type of the role assignment schedule expiration. Possible values include: 'AfterDuration', 'AfterDateTime', 'NoExpiration' + Type Type `json:"type,omitempty"` + // EndDateTime - End DateTime of the role assignment schedule. + EndDateTime *date.Time `json:"endDateTime,omitempty"` + // Duration - Duration of the role assignment schedule in TimeSpan. + Duration *string `json:"duration,omitempty"` +} + +// RoleAssignmentScheduleRequestPropertiesTicketInfo ticket Info of the role assignment +type RoleAssignmentScheduleRequestPropertiesTicketInfo struct { + // TicketNumber - Ticket number for the role assignment + TicketNumber *string `json:"ticketNumber,omitempty"` + // TicketSystem - Ticket system name for the role assignment + TicketSystem *string `json:"ticketSystem,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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rdlr RoleDefinitionListResult) hasNextLink() bool { + return rdlr.NextLink != nil && len(*rdlr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.rdlr) + if err != nil { + return err + } + page.rdlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur RoleDefinitionListResult, getNextPage func(context.Context, RoleDefinitionListResult) (RoleDefinitionListResult, error)) RoleDefinitionListResultPage { + return RoleDefinitionListResultPage{ + fn: getNextPage, + rdlr: cur, + } +} + +// 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"` +} + +// RoleEligibilitySchedule role eligibility schedule +type RoleEligibilitySchedule struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The role eligibility schedule Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The role eligibility schedule name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The role eligibility schedule type. + Type *string `json:"type,omitempty"` + // RoleEligibilityScheduleProperties - role eligibility schedule properties. + *RoleEligibilityScheduleProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleEligibilitySchedule. +func (res RoleEligibilitySchedule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if res.RoleEligibilityScheduleProperties != nil { + objectMap["properties"] = res.RoleEligibilityScheduleProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RoleEligibilitySchedule struct. +func (res *RoleEligibilitySchedule) 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 + } + res.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + res.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + res.Type = &typeVar + } + case "properties": + if v != nil { + var roleEligibilityScheduleProperties RoleEligibilityScheduleProperties + err = json.Unmarshal(*v, &roleEligibilityScheduleProperties) + if err != nil { + return err + } + res.RoleEligibilityScheduleProperties = &roleEligibilityScheduleProperties + } + } + } + + return nil +} + +// RoleEligibilityScheduleFilter role eligibility schedule filter +type RoleEligibilityScheduleFilter struct { + // PrincipalID - Returns role eligibility schedule of the specific principal. + PrincipalID *string `json:"principalId,omitempty"` + // RoleDefinitionID - Returns role eligibility schedule of the specific role definition. + RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` + // Status - Returns role eligibility schedule of the specific status. + Status *string `json:"status,omitempty"` +} + +// RoleEligibilityScheduleInstance information about current or upcoming role eligibility schedule instance +type RoleEligibilityScheduleInstance struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The role eligibility schedule instance ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The role eligibility schedule instance name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The role eligibility schedule instance type. + Type *string `json:"type,omitempty"` + // RoleEligibilityScheduleInstanceProperties - Role eligibility schedule instance properties. + *RoleEligibilityScheduleInstanceProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleEligibilityScheduleInstance. +func (resi RoleEligibilityScheduleInstance) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if resi.RoleEligibilityScheduleInstanceProperties != nil { + objectMap["properties"] = resi.RoleEligibilityScheduleInstanceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RoleEligibilityScheduleInstance struct. +func (resi *RoleEligibilityScheduleInstance) 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 + } + resi.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + resi.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + resi.Type = &typeVar + } + case "properties": + if v != nil { + var roleEligibilityScheduleInstanceProperties RoleEligibilityScheduleInstanceProperties + err = json.Unmarshal(*v, &roleEligibilityScheduleInstanceProperties) + if err != nil { + return err + } + resi.RoleEligibilityScheduleInstanceProperties = &roleEligibilityScheduleInstanceProperties + } + } + } + + return nil +} + +// RoleEligibilityScheduleInstanceFilter role eligibility schedule instance filter +type RoleEligibilityScheduleInstanceFilter struct { + // PrincipalID - Returns role eligibility schedule instances of the specific principal. + PrincipalID *string `json:"principalId,omitempty"` + // RoleDefinitionID - Returns role eligibility schedule instances of the specific role definition. + RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` + // Status - Returns role eligibility schedule instances of the specific status. + Status *string `json:"status,omitempty"` + // RoleEligibilityScheduleID - Returns role eligibility schedule instances belonging to a specific role eligibility schedule. + RoleEligibilityScheduleID *string `json:"roleEligibilityScheduleId,omitempty"` +} + +// RoleEligibilityScheduleInstanceListResult role eligibility schedule instance list operation result. +type RoleEligibilityScheduleInstanceListResult struct { + autorest.Response `json:"-"` + // Value - Role eligibility schedule instance list. + Value *[]RoleEligibilityScheduleInstance `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// RoleEligibilityScheduleInstanceListResultIterator provides access to a complete listing of +// RoleEligibilityScheduleInstance values. +type RoleEligibilityScheduleInstanceListResultIterator struct { + i int + page RoleEligibilityScheduleInstanceListResultPage +} + +// 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 *RoleEligibilityScheduleInstanceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleEligibilityScheduleInstanceListResultIterator.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 *RoleEligibilityScheduleInstanceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RoleEligibilityScheduleInstanceListResultIterator) 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 RoleEligibilityScheduleInstanceListResultIterator) Response() RoleEligibilityScheduleInstanceListResult { + 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 RoleEligibilityScheduleInstanceListResultIterator) Value() RoleEligibilityScheduleInstance { + if !iter.page.NotDone() { + return RoleEligibilityScheduleInstance{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RoleEligibilityScheduleInstanceListResultIterator type. +func NewRoleEligibilityScheduleInstanceListResultIterator(page RoleEligibilityScheduleInstanceListResultPage) RoleEligibilityScheduleInstanceListResultIterator { + return RoleEligibilityScheduleInstanceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (resilr RoleEligibilityScheduleInstanceListResult) IsEmpty() bool { + return resilr.Value == nil || len(*resilr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (resilr RoleEligibilityScheduleInstanceListResult) hasNextLink() bool { + return resilr.NextLink != nil && len(*resilr.NextLink) != 0 +} + +// roleEligibilityScheduleInstanceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (resilr RoleEligibilityScheduleInstanceListResult) roleEligibilityScheduleInstanceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !resilr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(resilr.NextLink))) +} + +// RoleEligibilityScheduleInstanceListResultPage contains a page of RoleEligibilityScheduleInstance values. +type RoleEligibilityScheduleInstanceListResultPage struct { + fn func(context.Context, RoleEligibilityScheduleInstanceListResult) (RoleEligibilityScheduleInstanceListResult, error) + resilr RoleEligibilityScheduleInstanceListResult +} + +// 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 *RoleEligibilityScheduleInstanceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleEligibilityScheduleInstanceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.resilr) + if err != nil { + return err + } + page.resilr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RoleEligibilityScheduleInstanceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RoleEligibilityScheduleInstanceListResultPage) NotDone() bool { + return !page.resilr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RoleEligibilityScheduleInstanceListResultPage) Response() RoleEligibilityScheduleInstanceListResult { + return page.resilr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RoleEligibilityScheduleInstanceListResultPage) Values() []RoleEligibilityScheduleInstance { + if page.resilr.IsEmpty() { + return nil + } + return *page.resilr.Value +} + +// Creates a new instance of the RoleEligibilityScheduleInstanceListResultPage type. +func NewRoleEligibilityScheduleInstanceListResultPage(cur RoleEligibilityScheduleInstanceListResult, getNextPage func(context.Context, RoleEligibilityScheduleInstanceListResult) (RoleEligibilityScheduleInstanceListResult, error)) RoleEligibilityScheduleInstanceListResultPage { + return RoleEligibilityScheduleInstanceListResultPage{ + fn: getNextPage, + resilr: cur, + } +} + +// RoleEligibilityScheduleInstanceProperties role eligibility schedule properties with scope. +type RoleEligibilityScheduleInstanceProperties struct { + // Scope - The role eligibility schedule 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: 'PrincipalTypeUser', 'PrincipalTypeGroup', 'PrincipalTypeServicePrincipal', 'PrincipalTypeForeignGroup', 'PrincipalTypeDevice' + PrincipalType PrincipalType `json:"principalType,omitempty"` + // RoleEligibilityScheduleID - Id of the master role eligibility schedule + RoleEligibilityScheduleID *string `json:"roleEligibilityScheduleId,omitempty"` + // Status - The status of the role eligibility schedule instance. Possible values include: 'Accepted', 'PendingEvaluation', 'Granted', 'Denied', 'PendingProvisioning', 'Provisioned', 'PendingRevocation', 'Revoked', 'Canceled', 'Failed', 'PendingApprovalProvisioning', 'PendingApproval', 'FailedAsResourceIsLocked', 'PendingAdminDecision', 'AdminApproved', 'AdminDenied', 'TimedOut', 'ProvisioningStarted', 'Invalid', 'PendingScheduleCreation', 'ScheduleCreated', 'PendingExternalProvisioning' + Status Status `json:"status,omitempty"` + // StartDateTime - The startDateTime of the role eligibility schedule instance + StartDateTime *date.Time `json:"startDateTime,omitempty"` + // EndDateTime - The endDateTime of the role eligibility schedule instance + EndDateTime *date.Time `json:"endDateTime,omitempty"` + // MemberType - Membership type of the role eligibility schedule. Possible values include: 'Inherited', 'Direct', 'Group' + MemberType MemberType `json:"memberType,omitempty"` + // Condition - The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container' + Condition *string `json:"condition,omitempty"` + // ConditionVersion - Version of the condition. Currently accepted value is '2.0' + ConditionVersion *string `json:"conditionVersion,omitempty"` + // CreatedOn - DateTime when role eligibility schedule was created + CreatedOn *date.Time `json:"createdOn,omitempty"` + // ExpandedProperties - Additional properties of principal, scope and role definition + ExpandedProperties *ExpandedProperties `json:"expandedProperties,omitempty"` +} + +// RoleEligibilityScheduleListResult role eligibility schedule list operation result. +type RoleEligibilityScheduleListResult struct { + autorest.Response `json:"-"` + // Value - role eligibility schedule list. + Value *[]RoleEligibilitySchedule `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// RoleEligibilityScheduleListResultIterator provides access to a complete listing of +// RoleEligibilitySchedule values. +type RoleEligibilityScheduleListResultIterator struct { + i int + page RoleEligibilityScheduleListResultPage +} + +// 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 *RoleEligibilityScheduleListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleEligibilityScheduleListResultIterator.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 *RoleEligibilityScheduleListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RoleEligibilityScheduleListResultIterator) 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 RoleEligibilityScheduleListResultIterator) Response() RoleEligibilityScheduleListResult { + 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 RoleEligibilityScheduleListResultIterator) Value() RoleEligibilitySchedule { + if !iter.page.NotDone() { + return RoleEligibilitySchedule{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RoleEligibilityScheduleListResultIterator type. +func NewRoleEligibilityScheduleListResultIterator(page RoleEligibilityScheduleListResultPage) RoleEligibilityScheduleListResultIterator { + return RoleEligibilityScheduleListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (reslr RoleEligibilityScheduleListResult) IsEmpty() bool { + return reslr.Value == nil || len(*reslr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (reslr RoleEligibilityScheduleListResult) hasNextLink() bool { + return reslr.NextLink != nil && len(*reslr.NextLink) != 0 +} + +// roleEligibilityScheduleListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (reslr RoleEligibilityScheduleListResult) roleEligibilityScheduleListResultPreparer(ctx context.Context) (*http.Request, error) { + if !reslr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(reslr.NextLink))) +} + +// RoleEligibilityScheduleListResultPage contains a page of RoleEligibilitySchedule values. +type RoleEligibilityScheduleListResultPage struct { + fn func(context.Context, RoleEligibilityScheduleListResult) (RoleEligibilityScheduleListResult, error) + reslr RoleEligibilityScheduleListResult +} + +// 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 *RoleEligibilityScheduleListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleEligibilityScheduleListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.reslr) + if err != nil { + return err + } + page.reslr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RoleEligibilityScheduleListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RoleEligibilityScheduleListResultPage) NotDone() bool { + return !page.reslr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RoleEligibilityScheduleListResultPage) Response() RoleEligibilityScheduleListResult { + return page.reslr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RoleEligibilityScheduleListResultPage) Values() []RoleEligibilitySchedule { + if page.reslr.IsEmpty() { + return nil + } + return *page.reslr.Value +} + +// Creates a new instance of the RoleEligibilityScheduleListResultPage type. +func NewRoleEligibilityScheduleListResultPage(cur RoleEligibilityScheduleListResult, getNextPage func(context.Context, RoleEligibilityScheduleListResult) (RoleEligibilityScheduleListResult, error)) RoleEligibilityScheduleListResultPage { + return RoleEligibilityScheduleListResultPage{ + fn: getNextPage, + reslr: cur, + } +} + +// RoleEligibilityScheduleProperties role eligibility schedule properties with scope. +type RoleEligibilityScheduleProperties struct { + // Scope - The role eligibility schedule 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: 'PrincipalTypeUser', 'PrincipalTypeGroup', 'PrincipalTypeServicePrincipal', 'PrincipalTypeForeignGroup', 'PrincipalTypeDevice' + PrincipalType PrincipalType `json:"principalType,omitempty"` + // RoleEligibilityScheduleRequestID - The id of roleEligibilityScheduleRequest used to create this roleAssignmentSchedule + RoleEligibilityScheduleRequestID *string `json:"roleEligibilityScheduleRequestId,omitempty"` + // MemberType - Membership type of the role eligibility schedule. Possible values include: 'Inherited', 'Direct', 'Group' + MemberType MemberType `json:"memberType,omitempty"` + // Status - The status of the role eligibility schedule. Possible values include: 'Accepted', 'PendingEvaluation', 'Granted', 'Denied', 'PendingProvisioning', 'Provisioned', 'PendingRevocation', 'Revoked', 'Canceled', 'Failed', 'PendingApprovalProvisioning', 'PendingApproval', 'FailedAsResourceIsLocked', 'PendingAdminDecision', 'AdminApproved', 'AdminDenied', 'TimedOut', 'ProvisioningStarted', 'Invalid', 'PendingScheduleCreation', 'ScheduleCreated', 'PendingExternalProvisioning' + Status Status `json:"status,omitempty"` + // StartDateTime - Start DateTime when role eligibility schedule + StartDateTime *date.Time `json:"startDateTime,omitempty"` + // EndDateTime - End DateTime when role eligibility schedule + EndDateTime *date.Time `json:"endDateTime,omitempty"` + // Condition - The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container' + Condition *string `json:"condition,omitempty"` + // ConditionVersion - Version of the condition. Currently accepted value is '2.0' + ConditionVersion *string `json:"conditionVersion,omitempty"` + // CreatedOn - DateTime when role eligibility schedule was created + CreatedOn *date.Time `json:"createdOn,omitempty"` + // UpdatedOn - DateTime when role eligibility schedule was modified + UpdatedOn *date.Time `json:"updatedOn,omitempty"` + // ExpandedProperties - Additional properties of principal, scope and role definition + ExpandedProperties *ExpandedProperties `json:"expandedProperties,omitempty"` +} + +// RoleEligibilityScheduleRequest role Eligibility schedule request +type RoleEligibilityScheduleRequest struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The role eligibility schedule request ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The role eligibility schedule request name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The role eligibility schedule request type. + Type *string `json:"type,omitempty"` + // RoleEligibilityScheduleRequestProperties - Role eligibility schedule request properties. + *RoleEligibilityScheduleRequestProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleEligibilityScheduleRequest. +func (resr RoleEligibilityScheduleRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if resr.RoleEligibilityScheduleRequestProperties != nil { + objectMap["properties"] = resr.RoleEligibilityScheduleRequestProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RoleEligibilityScheduleRequest struct. +func (resr *RoleEligibilityScheduleRequest) 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 + } + resr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + resr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + resr.Type = &typeVar + } + case "properties": + if v != nil { + var roleEligibilityScheduleRequestProperties RoleEligibilityScheduleRequestProperties + err = json.Unmarshal(*v, &roleEligibilityScheduleRequestProperties) + if err != nil { + return err + } + resr.RoleEligibilityScheduleRequestProperties = &roleEligibilityScheduleRequestProperties + } + } + } + + return nil +} + +// RoleEligibilityScheduleRequestFilter role eligibility schedule request filter +type RoleEligibilityScheduleRequestFilter struct { + // PrincipalID - Returns role eligibility requests of the specific principal. + PrincipalID *string `json:"principalId,omitempty"` + // RoleDefinitionID - Returns role eligibility requests of the specific role definition. + RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` + // RequestorID - Returns role eligibility requests created by specific principal. + RequestorID *string `json:"requestorId,omitempty"` + // Status - Returns role eligibility requests of specific status. + Status *string `json:"status,omitempty"` +} + +// RoleEligibilityScheduleRequestListResult role eligibility schedule request list operation result. +type RoleEligibilityScheduleRequestListResult struct { + autorest.Response `json:"-"` + // Value - Role eligibility schedule request list. + Value *[]RoleEligibilityScheduleRequest `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// RoleEligibilityScheduleRequestListResultIterator provides access to a complete listing of +// RoleEligibilityScheduleRequest values. +type RoleEligibilityScheduleRequestListResultIterator struct { + i int + page RoleEligibilityScheduleRequestListResultPage +} + +// 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 *RoleEligibilityScheduleRequestListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleEligibilityScheduleRequestListResultIterator.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 *RoleEligibilityScheduleRequestListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RoleEligibilityScheduleRequestListResultIterator) 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 RoleEligibilityScheduleRequestListResultIterator) Response() RoleEligibilityScheduleRequestListResult { + 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 RoleEligibilityScheduleRequestListResultIterator) Value() RoleEligibilityScheduleRequest { + if !iter.page.NotDone() { + return RoleEligibilityScheduleRequest{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RoleEligibilityScheduleRequestListResultIterator type. +func NewRoleEligibilityScheduleRequestListResultIterator(page RoleEligibilityScheduleRequestListResultPage) RoleEligibilityScheduleRequestListResultIterator { + return RoleEligibilityScheduleRequestListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (resrlr RoleEligibilityScheduleRequestListResult) IsEmpty() bool { + return resrlr.Value == nil || len(*resrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (resrlr RoleEligibilityScheduleRequestListResult) hasNextLink() bool { + return resrlr.NextLink != nil && len(*resrlr.NextLink) != 0 +} + +// roleEligibilityScheduleRequestListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (resrlr RoleEligibilityScheduleRequestListResult) roleEligibilityScheduleRequestListResultPreparer(ctx context.Context) (*http.Request, error) { + if !resrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(resrlr.NextLink))) +} + +// RoleEligibilityScheduleRequestListResultPage contains a page of RoleEligibilityScheduleRequest values. +type RoleEligibilityScheduleRequestListResultPage struct { + fn func(context.Context, RoleEligibilityScheduleRequestListResult) (RoleEligibilityScheduleRequestListResult, error) + resrlr RoleEligibilityScheduleRequestListResult +} + +// 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 *RoleEligibilityScheduleRequestListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleEligibilityScheduleRequestListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.resrlr) + if err != nil { + return err + } + page.resrlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RoleEligibilityScheduleRequestListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RoleEligibilityScheduleRequestListResultPage) NotDone() bool { + return !page.resrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RoleEligibilityScheduleRequestListResultPage) Response() RoleEligibilityScheduleRequestListResult { + return page.resrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RoleEligibilityScheduleRequestListResultPage) Values() []RoleEligibilityScheduleRequest { + if page.resrlr.IsEmpty() { + return nil + } + return *page.resrlr.Value +} + +// Creates a new instance of the RoleEligibilityScheduleRequestListResultPage type. +func NewRoleEligibilityScheduleRequestListResultPage(cur RoleEligibilityScheduleRequestListResult, getNextPage func(context.Context, RoleEligibilityScheduleRequestListResult) (RoleEligibilityScheduleRequestListResult, error)) RoleEligibilityScheduleRequestListResultPage { + return RoleEligibilityScheduleRequestListResultPage{ + fn: getNextPage, + resrlr: cur, + } +} + +// RoleEligibilityScheduleRequestProperties role eligibility schedule request properties with scope. +type RoleEligibilityScheduleRequestProperties struct { + // Scope - READ-ONLY; The role eligibility schedule request 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 - READ-ONLY; The principal type of the assigned principal ID. Possible values include: 'PrincipalTypeUser', 'PrincipalTypeGroup', 'PrincipalTypeServicePrincipal', 'PrincipalTypeForeignGroup', 'PrincipalTypeDevice' + PrincipalType PrincipalType `json:"principalType,omitempty"` + // RequestType - The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc. Possible values include: 'AdminAssign', 'AdminRemove', 'AdminUpdate', 'AdminExtend', 'AdminRenew', 'SelfActivate', 'SelfDeactivate', 'SelfExtend', 'SelfRenew' + RequestType RequestType `json:"requestType,omitempty"` + // Status - READ-ONLY; The status of the role eligibility schedule request. Possible values include: 'Accepted', 'PendingEvaluation', 'Granted', 'Denied', 'PendingProvisioning', 'Provisioned', 'PendingRevocation', 'Revoked', 'Canceled', 'Failed', 'PendingApprovalProvisioning', 'PendingApproval', 'FailedAsResourceIsLocked', 'PendingAdminDecision', 'AdminApproved', 'AdminDenied', 'TimedOut', 'ProvisioningStarted', 'Invalid', 'PendingScheduleCreation', 'ScheduleCreated', 'PendingExternalProvisioning' + Status Status `json:"status,omitempty"` + // ApprovalID - READ-ONLY; The approvalId of the role eligibility schedule request. + ApprovalID *string `json:"approvalId,omitempty"` + // ScheduleInfo - Schedule info of the role eligibility schedule + ScheduleInfo *RoleEligibilityScheduleRequestPropertiesScheduleInfo `json:"scheduleInfo,omitempty"` + // TargetRoleEligibilityScheduleID - The resultant role eligibility schedule id or the role eligibility schedule id being updated + TargetRoleEligibilityScheduleID *string `json:"targetRoleEligibilityScheduleId,omitempty"` + // TargetRoleEligibilityScheduleInstanceID - The role eligibility schedule instance id being updated + TargetRoleEligibilityScheduleInstanceID *string `json:"targetRoleEligibilityScheduleInstanceId,omitempty"` + // Justification - Justification for the role eligibility + Justification *string `json:"justification,omitempty"` + // TicketInfo - Ticket Info of the role eligibility + TicketInfo *RoleEligibilityScheduleRequestPropertiesTicketInfo `json:"ticketInfo,omitempty"` + // Condition - The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container' + Condition *string `json:"condition,omitempty"` + // ConditionVersion - Version of the condition. Currently accepted value is '2.0' + ConditionVersion *string `json:"conditionVersion,omitempty"` + // CreatedOn - READ-ONLY; DateTime when role eligibility schedule request was created + CreatedOn *date.Time `json:"createdOn,omitempty"` + // RequestorID - READ-ONLY; Id of the user who created this request + RequestorID *string `json:"requestorId,omitempty"` + // ExpandedProperties - READ-ONLY; Additional properties of principal, scope and role definition + ExpandedProperties *ExpandedProperties `json:"expandedProperties,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleEligibilityScheduleRequestProperties. +func (resrp RoleEligibilityScheduleRequestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if resrp.RoleDefinitionID != nil { + objectMap["roleDefinitionId"] = resrp.RoleDefinitionID + } + if resrp.PrincipalID != nil { + objectMap["principalId"] = resrp.PrincipalID + } + if resrp.RequestType != "" { + objectMap["requestType"] = resrp.RequestType + } + if resrp.ScheduleInfo != nil { + objectMap["scheduleInfo"] = resrp.ScheduleInfo + } + if resrp.TargetRoleEligibilityScheduleID != nil { + objectMap["targetRoleEligibilityScheduleId"] = resrp.TargetRoleEligibilityScheduleID + } + if resrp.TargetRoleEligibilityScheduleInstanceID != nil { + objectMap["targetRoleEligibilityScheduleInstanceId"] = resrp.TargetRoleEligibilityScheduleInstanceID + } + if resrp.Justification != nil { + objectMap["justification"] = resrp.Justification + } + if resrp.TicketInfo != nil { + objectMap["ticketInfo"] = resrp.TicketInfo + } + if resrp.Condition != nil { + objectMap["condition"] = resrp.Condition + } + if resrp.ConditionVersion != nil { + objectMap["conditionVersion"] = resrp.ConditionVersion + } + return json.Marshal(objectMap) +} + +// RoleEligibilityScheduleRequestPropertiesScheduleInfo schedule info of the role eligibility schedule +type RoleEligibilityScheduleRequestPropertiesScheduleInfo struct { + // StartDateTime - Start DateTime of the role eligibility schedule. + StartDateTime *date.Time `json:"startDateTime,omitempty"` + // Expiration - Expiration of the role eligibility schedule + Expiration *RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration `json:"expiration,omitempty"` +} + +// RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration expiration of the role eligibility +// schedule +type RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration struct { + // Type - Type of the role eligibility schedule expiration. Possible values include: 'AfterDuration', 'AfterDateTime', 'NoExpiration' + Type Type `json:"type,omitempty"` + // EndDateTime - End DateTime of the role eligibility schedule. + EndDateTime *date.Time `json:"endDateTime,omitempty"` + // Duration - Duration of the role eligibility schedule in TimeSpan. + Duration *string `json:"duration,omitempty"` +} + +// RoleEligibilityScheduleRequestPropertiesTicketInfo ticket Info of the role eligibility +type RoleEligibilityScheduleRequestPropertiesTicketInfo struct { + // TicketNumber - Ticket number for the role eligibility + TicketNumber *string `json:"ticketNumber,omitempty"` + // TicketSystem - Ticket system name for the role eligibility + TicketSystem *string `json:"ticketSystem,omitempty"` +} + +// RoleManagementPolicy role management policy +type RoleManagementPolicy struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The role management policy Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The role management policy name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The role management policy type. + Type *string `json:"type,omitempty"` + // RoleManagementPolicyProperties - Role management policy properties. + *RoleManagementPolicyProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleManagementPolicy. +func (rmp RoleManagementPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rmp.RoleManagementPolicyProperties != nil { + objectMap["properties"] = rmp.RoleManagementPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RoleManagementPolicy struct. +func (rmp *RoleManagementPolicy) 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 + } + rmp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rmp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rmp.Type = &typeVar + } + case "properties": + if v != nil { + var roleManagementPolicyProperties RoleManagementPolicyProperties + err = json.Unmarshal(*v, &roleManagementPolicyProperties) + if err != nil { + return err + } + rmp.RoleManagementPolicyProperties = &roleManagementPolicyProperties + } + } + } + + return nil +} + +// RoleManagementPolicyApprovalRule the role management policy rule. +type RoleManagementPolicyApprovalRule struct { + // Setting - The approval setting + Setting *ApprovalSettings `json:"setting,omitempty"` + // ID - The id of the rule. + ID *string `json:"id,omitempty"` + // Target - The target of the current rule. + Target *RoleManagementPolicyRuleTarget `json:"target,omitempty"` + // RuleType - Possible values include: 'RuleTypeRoleManagementPolicyRule', 'RuleTypeRoleManagementPolicyApprovalRule', 'RuleTypeRoleManagementPolicyAuthenticationContextRule', 'RuleTypeRoleManagementPolicyEnablementRule', 'RuleTypeRoleManagementPolicyExpirationRule', 'RuleTypeRoleManagementPolicyNotificationRule' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleManagementPolicyApprovalRule. +func (rmpar RoleManagementPolicyApprovalRule) MarshalJSON() ([]byte, error) { + rmpar.RuleType = RuleTypeRoleManagementPolicyApprovalRule + objectMap := make(map[string]interface{}) + if rmpar.Setting != nil { + objectMap["setting"] = rmpar.Setting + } + if rmpar.ID != nil { + objectMap["id"] = rmpar.ID + } + if rmpar.Target != nil { + objectMap["target"] = rmpar.Target + } + if rmpar.RuleType != "" { + objectMap["ruleType"] = rmpar.RuleType + } + return json.Marshal(objectMap) +} + +// AsRoleManagementPolicyApprovalRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyApprovalRule. +func (rmpar RoleManagementPolicyApprovalRule) AsRoleManagementPolicyApprovalRule() (*RoleManagementPolicyApprovalRule, bool) { + return &rmpar, true +} + +// AsRoleManagementPolicyAuthenticationContextRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyApprovalRule. +func (rmpar RoleManagementPolicyApprovalRule) AsRoleManagementPolicyAuthenticationContextRule() (*RoleManagementPolicyAuthenticationContextRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyEnablementRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyApprovalRule. +func (rmpar RoleManagementPolicyApprovalRule) AsRoleManagementPolicyEnablementRule() (*RoleManagementPolicyEnablementRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyExpirationRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyApprovalRule. +func (rmpar RoleManagementPolicyApprovalRule) AsRoleManagementPolicyExpirationRule() (*RoleManagementPolicyExpirationRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyNotificationRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyApprovalRule. +func (rmpar RoleManagementPolicyApprovalRule) AsRoleManagementPolicyNotificationRule() (*RoleManagementPolicyNotificationRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyApprovalRule. +func (rmpar RoleManagementPolicyApprovalRule) AsRoleManagementPolicyRule() (*RoleManagementPolicyRule, bool) { + return nil, false +} + +// AsBasicRoleManagementPolicyRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyApprovalRule. +func (rmpar RoleManagementPolicyApprovalRule) AsBasicRoleManagementPolicyRule() (BasicRoleManagementPolicyRule, bool) { + return &rmpar, true +} + +// RoleManagementPolicyAssignment role management policy +type RoleManagementPolicyAssignment struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The role management policy Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The role management policy name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The role management policy type. + Type *string `json:"type,omitempty"` + // RoleManagementPolicyAssignmentProperties - Role management policy properties. + *RoleManagementPolicyAssignmentProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleManagementPolicyAssignment. +func (rmpa RoleManagementPolicyAssignment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rmpa.RoleManagementPolicyAssignmentProperties != nil { + objectMap["properties"] = rmpa.RoleManagementPolicyAssignmentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RoleManagementPolicyAssignment struct. +func (rmpa *RoleManagementPolicyAssignment) 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 + } + rmpa.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rmpa.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rmpa.Type = &typeVar + } + case "properties": + if v != nil { + var roleManagementPolicyAssignmentProperties RoleManagementPolicyAssignmentProperties + err = json.Unmarshal(*v, &roleManagementPolicyAssignmentProperties) + if err != nil { + return err + } + rmpa.RoleManagementPolicyAssignmentProperties = &roleManagementPolicyAssignmentProperties + } + } + } + + return nil +} + +// RoleManagementPolicyAssignmentListResult role management policy assignment list operation result. +type RoleManagementPolicyAssignmentListResult struct { + autorest.Response `json:"-"` + // Value - Role management policy assignment list. + Value *[]RoleManagementPolicyAssignment `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// RoleManagementPolicyAssignmentListResultIterator provides access to a complete listing of +// RoleManagementPolicyAssignment values. +type RoleManagementPolicyAssignmentListResultIterator struct { + i int + page RoleManagementPolicyAssignmentListResultPage +} + +// 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 *RoleManagementPolicyAssignmentListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleManagementPolicyAssignmentListResultIterator.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 *RoleManagementPolicyAssignmentListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RoleManagementPolicyAssignmentListResultIterator) 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 RoleManagementPolicyAssignmentListResultIterator) Response() RoleManagementPolicyAssignmentListResult { + 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 RoleManagementPolicyAssignmentListResultIterator) Value() RoleManagementPolicyAssignment { + if !iter.page.NotDone() { + return RoleManagementPolicyAssignment{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RoleManagementPolicyAssignmentListResultIterator type. +func NewRoleManagementPolicyAssignmentListResultIterator(page RoleManagementPolicyAssignmentListResultPage) RoleManagementPolicyAssignmentListResultIterator { + return RoleManagementPolicyAssignmentListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rmpalr RoleManagementPolicyAssignmentListResult) IsEmpty() bool { + return rmpalr.Value == nil || len(*rmpalr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rmpalr RoleManagementPolicyAssignmentListResult) hasNextLink() bool { + return rmpalr.NextLink != nil && len(*rmpalr.NextLink) != 0 +} + +// roleManagementPolicyAssignmentListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rmpalr RoleManagementPolicyAssignmentListResult) roleManagementPolicyAssignmentListResultPreparer(ctx context.Context) (*http.Request, error) { + if !rmpalr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rmpalr.NextLink))) +} + +// RoleManagementPolicyAssignmentListResultPage contains a page of RoleManagementPolicyAssignment values. +type RoleManagementPolicyAssignmentListResultPage struct { + fn func(context.Context, RoleManagementPolicyAssignmentListResult) (RoleManagementPolicyAssignmentListResult, error) + rmpalr RoleManagementPolicyAssignmentListResult +} + +// 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 *RoleManagementPolicyAssignmentListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleManagementPolicyAssignmentListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rmpalr) + if err != nil { + return err + } + page.rmpalr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RoleManagementPolicyAssignmentListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RoleManagementPolicyAssignmentListResultPage) NotDone() bool { + return !page.rmpalr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RoleManagementPolicyAssignmentListResultPage) Response() RoleManagementPolicyAssignmentListResult { + return page.rmpalr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RoleManagementPolicyAssignmentListResultPage) Values() []RoleManagementPolicyAssignment { + if page.rmpalr.IsEmpty() { + return nil + } + return *page.rmpalr.Value +} + +// Creates a new instance of the RoleManagementPolicyAssignmentListResultPage type. +func NewRoleManagementPolicyAssignmentListResultPage(cur RoleManagementPolicyAssignmentListResult, getNextPage func(context.Context, RoleManagementPolicyAssignmentListResult) (RoleManagementPolicyAssignmentListResult, error)) RoleManagementPolicyAssignmentListResultPage { + return RoleManagementPolicyAssignmentListResultPage{ + fn: getNextPage, + rmpalr: cur, + } +} + +// RoleManagementPolicyAssignmentProperties role management policy assignment properties with scope. +type RoleManagementPolicyAssignmentProperties struct { + // Scope - The role management policy scope. + Scope *string `json:"scope,omitempty"` + // RoleDefinitionID - The role definition of management policy assignment. + RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` + // PolicyID - The policy id role management policy assignment. + PolicyID *string `json:"policyId,omitempty"` + // PolicyAssignmentProperties - READ-ONLY; Additional properties of scope, role definition and policy + PolicyAssignmentProperties *PolicyAssignmentProperties `json:"policyAssignmentProperties,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleManagementPolicyAssignmentProperties. +func (rmpap RoleManagementPolicyAssignmentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rmpap.Scope != nil { + objectMap["scope"] = rmpap.Scope + } + if rmpap.RoleDefinitionID != nil { + objectMap["roleDefinitionId"] = rmpap.RoleDefinitionID + } + if rmpap.PolicyID != nil { + objectMap["policyId"] = rmpap.PolicyID + } + return json.Marshal(objectMap) +} + +// RoleManagementPolicyAuthenticationContextRule the role management policy rule. +type RoleManagementPolicyAuthenticationContextRule struct { + // IsEnabled - The value indicating if rule is enabled. + IsEnabled *bool `json:"isEnabled,omitempty"` + // ClaimValue - The claim value. + ClaimValue *string `json:"claimValue,omitempty"` + // ID - The id of the rule. + ID *string `json:"id,omitempty"` + // Target - The target of the current rule. + Target *RoleManagementPolicyRuleTarget `json:"target,omitempty"` + // RuleType - Possible values include: 'RuleTypeRoleManagementPolicyRule', 'RuleTypeRoleManagementPolicyApprovalRule', 'RuleTypeRoleManagementPolicyAuthenticationContextRule', 'RuleTypeRoleManagementPolicyEnablementRule', 'RuleTypeRoleManagementPolicyExpirationRule', 'RuleTypeRoleManagementPolicyNotificationRule' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleManagementPolicyAuthenticationContextRule. +func (rmpacr RoleManagementPolicyAuthenticationContextRule) MarshalJSON() ([]byte, error) { + rmpacr.RuleType = RuleTypeRoleManagementPolicyAuthenticationContextRule + objectMap := make(map[string]interface{}) + if rmpacr.IsEnabled != nil { + objectMap["isEnabled"] = rmpacr.IsEnabled + } + if rmpacr.ClaimValue != nil { + objectMap["claimValue"] = rmpacr.ClaimValue + } + if rmpacr.ID != nil { + objectMap["id"] = rmpacr.ID + } + if rmpacr.Target != nil { + objectMap["target"] = rmpacr.Target + } + if rmpacr.RuleType != "" { + objectMap["ruleType"] = rmpacr.RuleType + } + return json.Marshal(objectMap) +} + +// AsRoleManagementPolicyApprovalRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyAuthenticationContextRule. +func (rmpacr RoleManagementPolicyAuthenticationContextRule) AsRoleManagementPolicyApprovalRule() (*RoleManagementPolicyApprovalRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyAuthenticationContextRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyAuthenticationContextRule. +func (rmpacr RoleManagementPolicyAuthenticationContextRule) AsRoleManagementPolicyAuthenticationContextRule() (*RoleManagementPolicyAuthenticationContextRule, bool) { + return &rmpacr, true +} + +// AsRoleManagementPolicyEnablementRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyAuthenticationContextRule. +func (rmpacr RoleManagementPolicyAuthenticationContextRule) AsRoleManagementPolicyEnablementRule() (*RoleManagementPolicyEnablementRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyExpirationRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyAuthenticationContextRule. +func (rmpacr RoleManagementPolicyAuthenticationContextRule) AsRoleManagementPolicyExpirationRule() (*RoleManagementPolicyExpirationRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyNotificationRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyAuthenticationContextRule. +func (rmpacr RoleManagementPolicyAuthenticationContextRule) AsRoleManagementPolicyNotificationRule() (*RoleManagementPolicyNotificationRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyAuthenticationContextRule. +func (rmpacr RoleManagementPolicyAuthenticationContextRule) AsRoleManagementPolicyRule() (*RoleManagementPolicyRule, bool) { + return nil, false +} + +// AsBasicRoleManagementPolicyRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyAuthenticationContextRule. +func (rmpacr RoleManagementPolicyAuthenticationContextRule) AsBasicRoleManagementPolicyRule() (BasicRoleManagementPolicyRule, bool) { + return &rmpacr, true +} + +// RoleManagementPolicyEnablementRule the role management policy rule. +type RoleManagementPolicyEnablementRule struct { + // EnabledRules - The list of enabled rules. + EnabledRules *[]EnablementRules `json:"enabledRules,omitempty"` + // ID - The id of the rule. + ID *string `json:"id,omitempty"` + // Target - The target of the current rule. + Target *RoleManagementPolicyRuleTarget `json:"target,omitempty"` + // RuleType - Possible values include: 'RuleTypeRoleManagementPolicyRule', 'RuleTypeRoleManagementPolicyApprovalRule', 'RuleTypeRoleManagementPolicyAuthenticationContextRule', 'RuleTypeRoleManagementPolicyEnablementRule', 'RuleTypeRoleManagementPolicyExpirationRule', 'RuleTypeRoleManagementPolicyNotificationRule' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleManagementPolicyEnablementRule. +func (rmper RoleManagementPolicyEnablementRule) MarshalJSON() ([]byte, error) { + rmper.RuleType = RuleTypeRoleManagementPolicyEnablementRule + objectMap := make(map[string]interface{}) + if rmper.EnabledRules != nil { + objectMap["enabledRules"] = rmper.EnabledRules + } + if rmper.ID != nil { + objectMap["id"] = rmper.ID + } + if rmper.Target != nil { + objectMap["target"] = rmper.Target + } + if rmper.RuleType != "" { + objectMap["ruleType"] = rmper.RuleType + } + return json.Marshal(objectMap) +} + +// AsRoleManagementPolicyApprovalRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyEnablementRule. +func (rmper RoleManagementPolicyEnablementRule) AsRoleManagementPolicyApprovalRule() (*RoleManagementPolicyApprovalRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyAuthenticationContextRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyEnablementRule. +func (rmper RoleManagementPolicyEnablementRule) AsRoleManagementPolicyAuthenticationContextRule() (*RoleManagementPolicyAuthenticationContextRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyEnablementRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyEnablementRule. +func (rmper RoleManagementPolicyEnablementRule) AsRoleManagementPolicyEnablementRule() (*RoleManagementPolicyEnablementRule, bool) { + return &rmper, true +} + +// AsRoleManagementPolicyExpirationRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyEnablementRule. +func (rmper RoleManagementPolicyEnablementRule) AsRoleManagementPolicyExpirationRule() (*RoleManagementPolicyExpirationRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyNotificationRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyEnablementRule. +func (rmper RoleManagementPolicyEnablementRule) AsRoleManagementPolicyNotificationRule() (*RoleManagementPolicyNotificationRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyEnablementRule. +func (rmper RoleManagementPolicyEnablementRule) AsRoleManagementPolicyRule() (*RoleManagementPolicyRule, bool) { + return nil, false +} + +// AsBasicRoleManagementPolicyRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyEnablementRule. +func (rmper RoleManagementPolicyEnablementRule) AsBasicRoleManagementPolicyRule() (BasicRoleManagementPolicyRule, bool) { + return &rmper, true +} + +// RoleManagementPolicyExpirationRule the role management policy rule. +type RoleManagementPolicyExpirationRule struct { + // IsExpirationRequired - The value indicating whether expiration is required. + IsExpirationRequired *bool `json:"isExpirationRequired,omitempty"` + // MaximumDuration - The maximum duration of expiration in timespan. + MaximumDuration *string `json:"maximumDuration,omitempty"` + // ID - The id of the rule. + ID *string `json:"id,omitempty"` + // Target - The target of the current rule. + Target *RoleManagementPolicyRuleTarget `json:"target,omitempty"` + // RuleType - Possible values include: 'RuleTypeRoleManagementPolicyRule', 'RuleTypeRoleManagementPolicyApprovalRule', 'RuleTypeRoleManagementPolicyAuthenticationContextRule', 'RuleTypeRoleManagementPolicyEnablementRule', 'RuleTypeRoleManagementPolicyExpirationRule', 'RuleTypeRoleManagementPolicyNotificationRule' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleManagementPolicyExpirationRule. +func (rmper RoleManagementPolicyExpirationRule) MarshalJSON() ([]byte, error) { + rmper.RuleType = RuleTypeRoleManagementPolicyExpirationRule + objectMap := make(map[string]interface{}) + if rmper.IsExpirationRequired != nil { + objectMap["isExpirationRequired"] = rmper.IsExpirationRequired + } + if rmper.MaximumDuration != nil { + objectMap["maximumDuration"] = rmper.MaximumDuration + } + if rmper.ID != nil { + objectMap["id"] = rmper.ID + } + if rmper.Target != nil { + objectMap["target"] = rmper.Target + } + if rmper.RuleType != "" { + objectMap["ruleType"] = rmper.RuleType + } + return json.Marshal(objectMap) +} + +// AsRoleManagementPolicyApprovalRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyExpirationRule. +func (rmper RoleManagementPolicyExpirationRule) AsRoleManagementPolicyApprovalRule() (*RoleManagementPolicyApprovalRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyAuthenticationContextRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyExpirationRule. +func (rmper RoleManagementPolicyExpirationRule) AsRoleManagementPolicyAuthenticationContextRule() (*RoleManagementPolicyAuthenticationContextRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyEnablementRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyExpirationRule. +func (rmper RoleManagementPolicyExpirationRule) AsRoleManagementPolicyEnablementRule() (*RoleManagementPolicyEnablementRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyExpirationRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyExpirationRule. +func (rmper RoleManagementPolicyExpirationRule) AsRoleManagementPolicyExpirationRule() (*RoleManagementPolicyExpirationRule, bool) { + return &rmper, true +} + +// AsRoleManagementPolicyNotificationRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyExpirationRule. +func (rmper RoleManagementPolicyExpirationRule) AsRoleManagementPolicyNotificationRule() (*RoleManagementPolicyNotificationRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyExpirationRule. +func (rmper RoleManagementPolicyExpirationRule) AsRoleManagementPolicyRule() (*RoleManagementPolicyRule, bool) { + return nil, false +} + +// AsBasicRoleManagementPolicyRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyExpirationRule. +func (rmper RoleManagementPolicyExpirationRule) AsBasicRoleManagementPolicyRule() (BasicRoleManagementPolicyRule, bool) { + return &rmper, true +} + +// RoleManagementPolicyListResult role management policy list operation result. +type RoleManagementPolicyListResult struct { + autorest.Response `json:"-"` + // Value - Role management policy list. + Value *[]RoleManagementPolicy `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// RoleManagementPolicyListResultIterator provides access to a complete listing of RoleManagementPolicy +// values. +type RoleManagementPolicyListResultIterator struct { + i int + page RoleManagementPolicyListResultPage +} + +// 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 *RoleManagementPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleManagementPolicyListResultIterator.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 *RoleManagementPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RoleManagementPolicyListResultIterator) 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 RoleManagementPolicyListResultIterator) Response() RoleManagementPolicyListResult { + 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 RoleManagementPolicyListResultIterator) Value() RoleManagementPolicy { + if !iter.page.NotDone() { + return RoleManagementPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RoleManagementPolicyListResultIterator type. +func NewRoleManagementPolicyListResultIterator(page RoleManagementPolicyListResultPage) RoleManagementPolicyListResultIterator { + return RoleManagementPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rmplr RoleManagementPolicyListResult) IsEmpty() bool { + return rmplr.Value == nil || len(*rmplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rmplr RoleManagementPolicyListResult) hasNextLink() bool { + return rmplr.NextLink != nil && len(*rmplr.NextLink) != 0 +} + +// roleManagementPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rmplr RoleManagementPolicyListResult) roleManagementPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !rmplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rmplr.NextLink))) +} + +// RoleManagementPolicyListResultPage contains a page of RoleManagementPolicy values. +type RoleManagementPolicyListResultPage struct { + fn func(context.Context, RoleManagementPolicyListResult) (RoleManagementPolicyListResult, error) + rmplr RoleManagementPolicyListResult +} + +// 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 *RoleManagementPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleManagementPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rmplr) + if err != nil { + return err + } + page.rmplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RoleManagementPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RoleManagementPolicyListResultPage) NotDone() bool { + return !page.rmplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RoleManagementPolicyListResultPage) Response() RoleManagementPolicyListResult { + return page.rmplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RoleManagementPolicyListResultPage) Values() []RoleManagementPolicy { + if page.rmplr.IsEmpty() { + return nil + } + return *page.rmplr.Value +} + +// Creates a new instance of the RoleManagementPolicyListResultPage type. +func NewRoleManagementPolicyListResultPage(cur RoleManagementPolicyListResult, getNextPage func(context.Context, RoleManagementPolicyListResult) (RoleManagementPolicyListResult, error)) RoleManagementPolicyListResultPage { + return RoleManagementPolicyListResultPage{ + fn: getNextPage, + rmplr: cur, + } +} + +// RoleManagementPolicyNotificationRule the role management policy rule. +type RoleManagementPolicyNotificationRule struct { + // NotificationType - The type of notification. Possible values include: 'Email' + NotificationType NotificationDeliveryMechanism `json:"notificationType,omitempty"` + // NotificationLevel - The notification level. Possible values include: 'None', 'Critical', 'All' + NotificationLevel NotificationLevel `json:"notificationLevel,omitempty"` + // RecipientType - The recipient type. Possible values include: 'Requestor', 'Approver', 'Admin' + RecipientType RecipientType `json:"recipientType,omitempty"` + // NotificationRecipients - The list notification recipients. + NotificationRecipients *[]string `json:"notificationRecipients,omitempty"` + // IsDefaultRecipientsEnabled - Its value determine if the notification need to be sent to the recipient type specified in policy rule. + IsDefaultRecipientsEnabled *bool `json:"isDefaultRecipientsEnabled,omitempty"` + // ID - The id of the rule. + ID *string `json:"id,omitempty"` + // Target - The target of the current rule. + Target *RoleManagementPolicyRuleTarget `json:"target,omitempty"` + // RuleType - Possible values include: 'RuleTypeRoleManagementPolicyRule', 'RuleTypeRoleManagementPolicyApprovalRule', 'RuleTypeRoleManagementPolicyAuthenticationContextRule', 'RuleTypeRoleManagementPolicyEnablementRule', 'RuleTypeRoleManagementPolicyExpirationRule', 'RuleTypeRoleManagementPolicyNotificationRule' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleManagementPolicyNotificationRule. +func (rmpnr RoleManagementPolicyNotificationRule) MarshalJSON() ([]byte, error) { + rmpnr.RuleType = RuleTypeRoleManagementPolicyNotificationRule + objectMap := make(map[string]interface{}) + if rmpnr.NotificationType != "" { + objectMap["notificationType"] = rmpnr.NotificationType + } + if rmpnr.NotificationLevel != "" { + objectMap["notificationLevel"] = rmpnr.NotificationLevel + } + if rmpnr.RecipientType != "" { + objectMap["recipientType"] = rmpnr.RecipientType + } + if rmpnr.NotificationRecipients != nil { + objectMap["notificationRecipients"] = rmpnr.NotificationRecipients + } + if rmpnr.IsDefaultRecipientsEnabled != nil { + objectMap["isDefaultRecipientsEnabled"] = rmpnr.IsDefaultRecipientsEnabled + } + if rmpnr.ID != nil { + objectMap["id"] = rmpnr.ID + } + if rmpnr.Target != nil { + objectMap["target"] = rmpnr.Target + } + if rmpnr.RuleType != "" { + objectMap["ruleType"] = rmpnr.RuleType + } + return json.Marshal(objectMap) +} + +// AsRoleManagementPolicyApprovalRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyNotificationRule. +func (rmpnr RoleManagementPolicyNotificationRule) AsRoleManagementPolicyApprovalRule() (*RoleManagementPolicyApprovalRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyAuthenticationContextRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyNotificationRule. +func (rmpnr RoleManagementPolicyNotificationRule) AsRoleManagementPolicyAuthenticationContextRule() (*RoleManagementPolicyAuthenticationContextRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyEnablementRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyNotificationRule. +func (rmpnr RoleManagementPolicyNotificationRule) AsRoleManagementPolicyEnablementRule() (*RoleManagementPolicyEnablementRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyExpirationRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyNotificationRule. +func (rmpnr RoleManagementPolicyNotificationRule) AsRoleManagementPolicyExpirationRule() (*RoleManagementPolicyExpirationRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyNotificationRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyNotificationRule. +func (rmpnr RoleManagementPolicyNotificationRule) AsRoleManagementPolicyNotificationRule() (*RoleManagementPolicyNotificationRule, bool) { + return &rmpnr, true +} + +// AsRoleManagementPolicyRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyNotificationRule. +func (rmpnr RoleManagementPolicyNotificationRule) AsRoleManagementPolicyRule() (*RoleManagementPolicyRule, bool) { + return nil, false +} + +// AsBasicRoleManagementPolicyRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyNotificationRule. +func (rmpnr RoleManagementPolicyNotificationRule) AsBasicRoleManagementPolicyRule() (BasicRoleManagementPolicyRule, bool) { + return &rmpnr, true +} + +// RoleManagementPolicyProperties role management policy properties with scope. +type RoleManagementPolicyProperties struct { + // Scope - The role management policy scope. + Scope *string `json:"scope,omitempty"` + // DisplayName - The role management policy display name. + DisplayName *string `json:"displayName,omitempty"` + // Description - The role management policy description. + Description *string `json:"description,omitempty"` + // IsOrganizationDefault - The role management policy is default policy. + IsOrganizationDefault *bool `json:"isOrganizationDefault,omitempty"` + LastModifiedBy *Principal `json:"lastModifiedBy,omitempty"` + // LastModifiedDateTime - READ-ONLY; The last modified date time. + LastModifiedDateTime *date.Time `json:"lastModifiedDateTime,omitempty"` + // Rules - The rule applied to the policy. + Rules *[]BasicRoleManagementPolicyRule `json:"rules,omitempty"` + // EffectiveRules - READ-ONLY; The readonly computed rule applied to the policy. + EffectiveRules *[]BasicRoleManagementPolicyRule `json:"effectiveRules,omitempty"` + // PolicyProperties - READ-ONLY; Additional properties of scope + PolicyProperties *PolicyProperties `json:"policyProperties,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleManagementPolicyProperties. +func (rmpp RoleManagementPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rmpp.Scope != nil { + objectMap["scope"] = rmpp.Scope + } + if rmpp.DisplayName != nil { + objectMap["displayName"] = rmpp.DisplayName + } + if rmpp.Description != nil { + objectMap["description"] = rmpp.Description + } + if rmpp.IsOrganizationDefault != nil { + objectMap["isOrganizationDefault"] = rmpp.IsOrganizationDefault + } + if rmpp.LastModifiedBy != nil { + objectMap["lastModifiedBy"] = rmpp.LastModifiedBy + } + if rmpp.Rules != nil { + objectMap["rules"] = rmpp.Rules + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RoleManagementPolicyProperties struct. +func (rmpp *RoleManagementPolicyProperties) 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 "scope": + if v != nil { + var scope string + err = json.Unmarshal(*v, &scope) + if err != nil { + return err + } + rmpp.Scope = &scope + } + case "displayName": + if v != nil { + var displayName string + err = json.Unmarshal(*v, &displayName) + if err != nil { + return err + } + rmpp.DisplayName = &displayName + } + case "description": + if v != nil { + var description string + err = json.Unmarshal(*v, &description) + if err != nil { + return err + } + rmpp.Description = &description + } + case "isOrganizationDefault": + if v != nil { + var isOrganizationDefault bool + err = json.Unmarshal(*v, &isOrganizationDefault) + if err != nil { + return err + } + rmpp.IsOrganizationDefault = &isOrganizationDefault + } + case "lastModifiedBy": + if v != nil { + var lastModifiedBy Principal + err = json.Unmarshal(*v, &lastModifiedBy) + if err != nil { + return err + } + rmpp.LastModifiedBy = &lastModifiedBy + } + case "lastModifiedDateTime": + if v != nil { + var lastModifiedDateTime date.Time + err = json.Unmarshal(*v, &lastModifiedDateTime) + if err != nil { + return err + } + rmpp.LastModifiedDateTime = &lastModifiedDateTime + } + case "rules": + if v != nil { + rules, err := unmarshalBasicRoleManagementPolicyRuleArray(*v) + if err != nil { + return err + } + rmpp.Rules = &rules + } + case "effectiveRules": + if v != nil { + effectiveRules, err := unmarshalBasicRoleManagementPolicyRuleArray(*v) + if err != nil { + return err + } + rmpp.EffectiveRules = &effectiveRules + } + case "policyProperties": + if v != nil { + var policyProperties PolicyProperties + err = json.Unmarshal(*v, &policyProperties) + if err != nil { + return err + } + rmpp.PolicyProperties = &policyProperties + } + } + } + + return nil +} + +// BasicRoleManagementPolicyRule the role management policy rule. +type BasicRoleManagementPolicyRule interface { + AsRoleManagementPolicyApprovalRule() (*RoleManagementPolicyApprovalRule, bool) + AsRoleManagementPolicyAuthenticationContextRule() (*RoleManagementPolicyAuthenticationContextRule, bool) + AsRoleManagementPolicyEnablementRule() (*RoleManagementPolicyEnablementRule, bool) + AsRoleManagementPolicyExpirationRule() (*RoleManagementPolicyExpirationRule, bool) + AsRoleManagementPolicyNotificationRule() (*RoleManagementPolicyNotificationRule, bool) + AsRoleManagementPolicyRule() (*RoleManagementPolicyRule, bool) +} + +// RoleManagementPolicyRule the role management policy rule. +type RoleManagementPolicyRule struct { + // ID - The id of the rule. + ID *string `json:"id,omitempty"` + // Target - The target of the current rule. + Target *RoleManagementPolicyRuleTarget `json:"target,omitempty"` + // RuleType - Possible values include: 'RuleTypeRoleManagementPolicyRule', 'RuleTypeRoleManagementPolicyApprovalRule', 'RuleTypeRoleManagementPolicyAuthenticationContextRule', 'RuleTypeRoleManagementPolicyEnablementRule', 'RuleTypeRoleManagementPolicyExpirationRule', 'RuleTypeRoleManagementPolicyNotificationRule' + RuleType RuleType `json:"ruleType,omitempty"` +} + +func unmarshalBasicRoleManagementPolicyRule(body []byte) (BasicRoleManagementPolicyRule, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["ruleType"] { + case string(RuleTypeRoleManagementPolicyApprovalRule): + var rmpar RoleManagementPolicyApprovalRule + err := json.Unmarshal(body, &rmpar) + return rmpar, err + case string(RuleTypeRoleManagementPolicyAuthenticationContextRule): + var rmpacr RoleManagementPolicyAuthenticationContextRule + err := json.Unmarshal(body, &rmpacr) + return rmpacr, err + case string(RuleTypeRoleManagementPolicyEnablementRule): + var rmper RoleManagementPolicyEnablementRule + err := json.Unmarshal(body, &rmper) + return rmper, err + case string(RuleTypeRoleManagementPolicyExpirationRule): + var rmper RoleManagementPolicyExpirationRule + err := json.Unmarshal(body, &rmper) + return rmper, err + case string(RuleTypeRoleManagementPolicyNotificationRule): + var rmpnr RoleManagementPolicyNotificationRule + err := json.Unmarshal(body, &rmpnr) + return rmpnr, err + default: + var rmpr RoleManagementPolicyRule + err := json.Unmarshal(body, &rmpr) + return rmpr, err + } +} +func unmarshalBasicRoleManagementPolicyRuleArray(body []byte) ([]BasicRoleManagementPolicyRule, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + rmprArray := make([]BasicRoleManagementPolicyRule, len(rawMessages)) + + for index, rawMessage := range rawMessages { + rmpr, err := unmarshalBasicRoleManagementPolicyRule(*rawMessage) + if err != nil { + return nil, err + } + rmprArray[index] = rmpr + } + return rmprArray, nil +} + +// MarshalJSON is the custom marshaler for RoleManagementPolicyRule. +func (rmpr RoleManagementPolicyRule) MarshalJSON() ([]byte, error) { + rmpr.RuleType = RuleTypeRoleManagementPolicyRule + objectMap := make(map[string]interface{}) + if rmpr.ID != nil { + objectMap["id"] = rmpr.ID + } + if rmpr.Target != nil { + objectMap["target"] = rmpr.Target + } + if rmpr.RuleType != "" { + objectMap["ruleType"] = rmpr.RuleType + } + return json.Marshal(objectMap) +} + +// AsRoleManagementPolicyApprovalRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyRule. +func (rmpr RoleManagementPolicyRule) AsRoleManagementPolicyApprovalRule() (*RoleManagementPolicyApprovalRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyAuthenticationContextRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyRule. +func (rmpr RoleManagementPolicyRule) AsRoleManagementPolicyAuthenticationContextRule() (*RoleManagementPolicyAuthenticationContextRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyEnablementRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyRule. +func (rmpr RoleManagementPolicyRule) AsRoleManagementPolicyEnablementRule() (*RoleManagementPolicyEnablementRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyExpirationRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyRule. +func (rmpr RoleManagementPolicyRule) AsRoleManagementPolicyExpirationRule() (*RoleManagementPolicyExpirationRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyNotificationRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyRule. +func (rmpr RoleManagementPolicyRule) AsRoleManagementPolicyNotificationRule() (*RoleManagementPolicyNotificationRule, bool) { + return nil, false +} + +// AsRoleManagementPolicyRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyRule. +func (rmpr RoleManagementPolicyRule) AsRoleManagementPolicyRule() (*RoleManagementPolicyRule, bool) { + return &rmpr, true +} + +// AsBasicRoleManagementPolicyRule is the BasicRoleManagementPolicyRule implementation for RoleManagementPolicyRule. +func (rmpr RoleManagementPolicyRule) AsBasicRoleManagementPolicyRule() (BasicRoleManagementPolicyRule, bool) { + return &rmpr, true +} + +// RoleManagementPolicyRuleTarget the role management policy rule target. +type RoleManagementPolicyRuleTarget struct { + // Caller - The caller of the setting. + Caller *string `json:"caller,omitempty"` + // Operations - The type of operation. + Operations *[]string `json:"operations,omitempty"` + // Level - The assignment level to which it is applied. + Level *string `json:"level,omitempty"` + // TargetObjects - The list of target objects. + TargetObjects *[]string `json:"targetObjects,omitempty"` + // InheritableSettings - The list of inheritable settings. + InheritableSettings *[]string `json:"inheritableSettings,omitempty"` + // EnforcedSettings - The list of enforced settings. + EnforcedSettings *[]string `json:"enforcedSettings,omitempty"` +} + +// ServicePrincipalDecisionTarget service Principal Decision Target +type ServicePrincipalDecisionTarget struct { + // PrincipalID - READ-ONLY; The id of service principal whose access is reviewed. + PrincipalID *string `json:"principalId,omitempty"` + // PrincipalName - READ-ONLY; The display name of the service principal whose access was reviewed. + PrincipalName *string `json:"principalName,omitempty"` + // AppID - READ-ONLY; The appId for the service principal entity being reviewed + AppID *string `json:"appId,omitempty"` + // Type - Possible values include: 'TypeAccessReviewDecisionTarget', 'TypeUser', 'TypeServicePrincipal' + Type TypeBasicAccessReviewDecisionTarget `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServicePrincipalDecisionTarget. +func (spdt ServicePrincipalDecisionTarget) MarshalJSON() ([]byte, error) { + spdt.Type = TypeServicePrincipal + objectMap := make(map[string]interface{}) + if spdt.Type != "" { + objectMap["type"] = spdt.Type + } + return json.Marshal(objectMap) +} + +// AsUserDecisionTarget is the BasicAccessReviewDecisionTarget implementation for ServicePrincipalDecisionTarget. +func (spdt ServicePrincipalDecisionTarget) AsUserDecisionTarget() (*UserDecisionTarget, bool) { + return nil, false +} + +// AsServicePrincipalDecisionTarget is the BasicAccessReviewDecisionTarget implementation for ServicePrincipalDecisionTarget. +func (spdt ServicePrincipalDecisionTarget) AsServicePrincipalDecisionTarget() (*ServicePrincipalDecisionTarget, bool) { + return &spdt, true +} + +// AsAccessReviewDecisionTarget is the BasicAccessReviewDecisionTarget implementation for ServicePrincipalDecisionTarget. +func (spdt ServicePrincipalDecisionTarget) AsAccessReviewDecisionTarget() (*AccessReviewDecisionTarget, bool) { + return nil, false +} + +// AsBasicAccessReviewDecisionTarget is the BasicAccessReviewDecisionTarget implementation for ServicePrincipalDecisionTarget. +func (spdt ServicePrincipalDecisionTarget) AsBasicAccessReviewDecisionTarget() (BasicAccessReviewDecisionTarget, bool) { + return &spdt, true +} + +// UserDecisionTarget user Decision Target +type UserDecisionTarget struct { + // PrincipalID - READ-ONLY; The id of user whose access was reviewed. + PrincipalID *string `json:"principalId,omitempty"` + // PrincipalName - READ-ONLY; The display name of the user whose access was reviewed. + PrincipalName *string `json:"principalName,omitempty"` + // UserPrincipalName - READ-ONLY; The user principal name of the user whose access was reviewed. + UserPrincipalName *string `json:"userPrincipalName,omitempty"` + // Type - Possible values include: 'TypeAccessReviewDecisionTarget', 'TypeUser', 'TypeServicePrincipal' + Type TypeBasicAccessReviewDecisionTarget `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for UserDecisionTarget. +func (udt UserDecisionTarget) MarshalJSON() ([]byte, error) { + udt.Type = TypeUser + objectMap := make(map[string]interface{}) + if udt.Type != "" { + objectMap["type"] = udt.Type + } + return json.Marshal(objectMap) +} + +// AsUserDecisionTarget is the BasicAccessReviewDecisionTarget implementation for UserDecisionTarget. +func (udt UserDecisionTarget) AsUserDecisionTarget() (*UserDecisionTarget, bool) { + return &udt, true +} + +// AsServicePrincipalDecisionTarget is the BasicAccessReviewDecisionTarget implementation for UserDecisionTarget. +func (udt UserDecisionTarget) AsServicePrincipalDecisionTarget() (*ServicePrincipalDecisionTarget, bool) { + return nil, false +} + +// AsAccessReviewDecisionTarget is the BasicAccessReviewDecisionTarget implementation for UserDecisionTarget. +func (udt UserDecisionTarget) AsAccessReviewDecisionTarget() (*AccessReviewDecisionTarget, bool) { + return nil, false +} + +// AsBasicAccessReviewDecisionTarget is the BasicAccessReviewDecisionTarget implementation for UserDecisionTarget. +func (udt UserDecisionTarget) AsBasicAccessReviewDecisionTarget() (BasicAccessReviewDecisionTarget, bool) { + return &udt, true +} + +// UserSet the detail of a user. +type UserSet struct { + // UserType - The type of user. Possible values include: 'UserTypeUser', 'UserTypeGroup' + UserType UserType `json:"userType,omitempty"` + // IsBackup - The value indicating whether the user is a backup fallback approver + IsBackup *bool `json:"isBackup,omitempty"` + // ID - The object id of the user. + ID *string `json:"id,omitempty"` + // Description - The description of the user. + Description *string `json:"description,omitempty"` +} + +// ValidationResponse validation response +type ValidationResponse struct { + autorest.Response `json:"-"` + // IsValid - READ-ONLY; Whether or not validation succeeded + IsValid *bool `json:"isValid,omitempty"` + // ErrorInfo - Failed validation result details + ErrorInfo *ValidationResponseErrorInfo `json:"errorInfo,omitempty"` +} + +// MarshalJSON is the custom marshaler for ValidationResponse. +func (vr ValidationResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vr.ErrorInfo != nil { + objectMap["errorInfo"] = vr.ErrorInfo + } + return json.Marshal(objectMap) +} + +// ValidationResponseErrorInfo failed validation result details +type ValidationResponseErrorInfo struct { + // Code - READ-ONLY; Error code indicating why validation failed + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; Message indicating why validation failed + Message *string `json:"message,omitempty"` +} + +// MarshalJSON is the custom marshaler for ValidationResponseErrorInfo. +func (vrei ValidationResponseErrorInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} diff --git a/services/preview/authorization/mgmt/2020-10-01-preview/authorization/operations.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/operations.go new file mode 100644 index 000000000000..1fcf785b7904 --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/operations.go @@ -0,0 +1,140 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the client for the Operations methods of the Authorization service. +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists the operations available from this provider. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.OperationsClient", "List", resp, "Failure responding to request") + return + } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2018-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Authorization/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "authorization.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/preview/authorization/mgmt/2020-10-01-preview/authorization/permissions.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/permissions.go new file mode 100644 index 000000000000..307f7a567df8 --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/permissions.go @@ -0,0 +1,290 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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 using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +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. The name is case insensitive. +// 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) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.PermissionsClient", "ListForResource", err.Error()) + } + + 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 + } + if result.pgr.hasNextLink() && result.pgr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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": 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 client.Send(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, + 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. The name is case insensitive. +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) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.PermissionsClient", "ListForResourceGroup", err.Error()) + } + + 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 + } + if result.pgr.hasNextLink() && result.pgr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 client.Send(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, + 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/services/preview/authorization/mgmt/2020-10-01-preview/authorization/provideroperationsmetadata.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/provideroperationsmetadata.go new file mode 100644 index 000000000000..77cb8b9768e9 --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/provideroperationsmetadata.go @@ -0,0 +1,228 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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 +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +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 + } + + 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": 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 client.Send(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, + 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 + } + if result.pomlr.hasNextLink() && result.pomlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ProviderOperationsMetadataClient) ListResponder(resp *http.Response) (result ProviderOperationsMetadataListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client 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/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleassignmentmetrics.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleassignmentmetrics.go new file mode 100644 index 000000000000..5059d51a01e5 --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleassignmentmetrics.go @@ -0,0 +1,110 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RoleAssignmentMetricsClient is the client for the RoleAssignmentMetrics methods of the Authorization service. +type RoleAssignmentMetricsClient struct { + BaseClient +} + +// NewRoleAssignmentMetricsClient creates an instance of the RoleAssignmentMetricsClient client. +func NewRoleAssignmentMetricsClient(subscriptionID string) RoleAssignmentMetricsClient { + return NewRoleAssignmentMetricsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRoleAssignmentMetricsClientWithBaseURI creates an instance of the RoleAssignmentMetricsClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewRoleAssignmentMetricsClientWithBaseURI(baseURI string, subscriptionID string) RoleAssignmentMetricsClient { + return RoleAssignmentMetricsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// GetMetricsForSubscription get role assignment usage metrics for a subscription +func (client RoleAssignmentMetricsClient) GetMetricsForSubscription(ctx context.Context) (result RoleAssignmentMetricsResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentMetricsClient.GetMetricsForSubscription") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.RoleAssignmentMetricsClient", "GetMetricsForSubscription", err.Error()) + } + + req, err := client.GetMetricsForSubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentMetricsClient", "GetMetricsForSubscription", nil, "Failure preparing request") + return + } + + resp, err := client.GetMetricsForSubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentMetricsClient", "GetMetricsForSubscription", resp, "Failure sending request") + return + } + + result, err = client.GetMetricsForSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentMetricsClient", "GetMetricsForSubscription", resp, "Failure responding to request") + return + } + + return +} + +// GetMetricsForSubscriptionPreparer prepares the GetMetricsForSubscription request. +func (client RoleAssignmentMetricsClient) GetMetricsForSubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetMetricsForSubscriptionSender sends the GetMetricsForSubscription request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentMetricsClient) GetMetricsForSubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetMetricsForSubscriptionResponder handles the response to the GetMetricsForSubscription request. The method always +// closes the http.Response Body. +func (client RoleAssignmentMetricsClient) GetMetricsForSubscriptionResponder(resp *http.Response) (result RoleAssignmentMetricsResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleassignments.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleassignments.go new file mode 100644 index 000000000000..635f176ec700 --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleassignments.go @@ -0,0 +1,1247 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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 using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewRoleAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) RoleAssignmentsClient { + return RoleAssignmentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create or update a role assignment by scope and name. +// Parameters: +// scope - the scope of the operation or resource. Valid scopes are: subscription (format: +// '/subscriptions/{subscriptionId}'), resource group (format: +// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: +// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' +// roleAssignmentName - the name of the role assignment. 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 + } + + 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": roleAssignmentName, + "scope": scope, + } + + const APIVersion = "2020-10-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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateByID create or update a role assignment by ID. +// Parameters: +// roleAssignmentID - the fully qualified ID of the role assignment including scope, resource name, and +// resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. +// Example: +// /subscriptions//resourcegroups//providers/Microsoft.Authorization/roleAssignments/ +// parameters - parameters for the role assignment. +func (client RoleAssignmentsClient) CreateByID(ctx context.Context, roleAssignmentID 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, roleAssignmentID, 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 + } + + return +} + +// CreateByIDPreparer prepares the CreateByID request. +func (client RoleAssignmentsClient) CreateByIDPreparer(ctx context.Context, roleAssignmentID string, parameters RoleAssignmentCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleAssignmentId": roleAssignmentID, + } + + const APIVersion = "2020-10-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("/{roleAssignmentId}", 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a role assignment by scope and name. +// Parameters: +// scope - the scope of the operation or resource. Valid scopes are: subscription (format: +// '/subscriptions/{subscriptionId}'), resource group (format: +// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: +// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' +// roleAssignmentName - the name of the role assignment. It can be any valid GUID. +// tenantID - tenant ID for cross-tenant request +func (client RoleAssignmentsClient) Delete(ctx context.Context, scope string, roleAssignmentName string, tenantID 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, tenantID) + 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 + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client RoleAssignmentsClient) DeletePreparer(ctx context.Context, scope string, roleAssignmentName string, tenantID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleAssignmentName": roleAssignmentName, + "scope": scope, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(tenantID) > 0 { + queryParameters["tenantId"] = autorest.Encode("query", tenantID) + } + + 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteByID delete a role assignment by ID. +// Parameters: +// roleAssignmentID - the fully qualified ID of the role assignment including scope, resource name, and +// resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. +// Example: +// /subscriptions//resourcegroups//providers/Microsoft.Authorization/roleAssignments/ +// tenantID - tenant ID for cross-tenant request +func (client RoleAssignmentsClient) DeleteByID(ctx context.Context, roleAssignmentID string, tenantID 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, roleAssignmentID, tenantID) + 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 + } + + return +} + +// DeleteByIDPreparer prepares the DeleteByID request. +func (client RoleAssignmentsClient) DeleteByIDPreparer(ctx context.Context, roleAssignmentID string, tenantID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleAssignmentId": roleAssignmentID, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(tenantID) > 0 { + queryParameters["tenantId"] = autorest.Encode("query", tenantID) + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{roleAssignmentId}", 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get a role assignment by scope and name. +// Parameters: +// scope - the scope of the operation or resource. Valid scopes are: subscription (format: +// '/subscriptions/{subscriptionId}'), resource group (format: +// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: +// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' +// roleAssignmentName - the name of the role assignment. It can be any valid GUID. +// tenantID - tenant ID for cross-tenant request +func (client RoleAssignmentsClient) Get(ctx context.Context, scope string, roleAssignmentName string, tenantID 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, tenantID) + 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 + } + + return +} + +// GetPreparer prepares the Get request. +func (client RoleAssignmentsClient) GetPreparer(ctx context.Context, scope string, roleAssignmentName string, tenantID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleAssignmentName": roleAssignmentName, + "scope": scope, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(tenantID) > 0 { + queryParameters["tenantId"] = autorest.Encode("query", tenantID) + } + + 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByID get a role assignment by ID. +// Parameters: +// roleAssignmentID - the fully qualified ID of the role assignment including scope, resource name, and +// resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. +// Example: +// /subscriptions//resourcegroups//providers/Microsoft.Authorization/roleAssignments/ +// tenantID - tenant ID for cross-tenant request +func (client RoleAssignmentsClient) GetByID(ctx context.Context, roleAssignmentID string, tenantID 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, roleAssignmentID, tenantID) + 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 + } + + return +} + +// GetByIDPreparer prepares the GetByID request. +func (client RoleAssignmentsClient) GetByIDPreparer(ctx context.Context, roleAssignmentID string, tenantID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleAssignmentId": roleAssignmentID, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(tenantID) > 0 { + queryParameters["tenantId"] = autorest.Encode("query", tenantID) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{roleAssignmentId}", 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListForResource list all role assignments that apply to a resource. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceProviderNamespace - the namespace of the resource provider. +// resourceType - the resource type name. For example the type name of a web app is 'sites' (from +// Microsoft.Web/sites). +// resourceName - the resource name. +// 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. +// tenantID - tenant ID for cross-tenant request +func (client RoleAssignmentsClient) ListForResource(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, resourceType string, resourceName string, filter string, tenantID 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) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.RoleAssignmentsClient", "ListForResource", err.Error()) + } + + result.fn = client.listForResourceNextResults + req, err := client.ListForResourcePreparer(ctx, resourceGroupName, resourceProviderNamespace, resourceType, resourceName, filter, tenantID) + 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 + } + if result.ralr.hasNextLink() && result.ralr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListForResourcePreparer prepares the ListForResource request. +func (client RoleAssignmentsClient) ListForResourcePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, resourceType string, resourceName string, filter string, tenantID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": resourceName, + "resourceProviderNamespace": resourceProviderNamespace, + "resourceType": resourceType, + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = filter + } + if len(tenantID) > 0 { + queryParameters["tenantId"] = autorest.Encode("query", tenantID) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{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 client.Send(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, + 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, resourceType string, resourceName string, filter string, tenantID 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, resourceType, resourceName, filter, tenantID) + return +} + +// ListForResourceGroup list all role assignments that apply to a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// 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. +// tenantID - tenant ID for cross-tenant request +func (client RoleAssignmentsClient) ListForResourceGroup(ctx context.Context, resourceGroupName string, filter string, tenantID 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) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.RoleAssignmentsClient", "ListForResourceGroup", err.Error()) + } + + result.fn = client.listForResourceGroupNextResults + req, err := client.ListForResourceGroupPreparer(ctx, resourceGroupName, filter, tenantID) + 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 + } + if result.ralr.hasNextLink() && result.ralr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListForResourceGroupPreparer prepares the ListForResourceGroup request. +func (client RoleAssignmentsClient) ListForResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string, tenantID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = filter + } + if len(tenantID) > 0 { + queryParameters["tenantId"] = autorest.Encode("query", tenantID) + } + + 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 client.Send(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, + 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, tenantID 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, tenantID) + return +} + +// ListForScope list all role assignments that apply to a scope. +// Parameters: +// scope - the scope of the operation or resource. Valid scopes are: subscription (format: +// '/subscriptions/{subscriptionId}'), resource group (format: +// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: +// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' +// 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. +// tenantID - tenant ID for cross-tenant request +func (client RoleAssignmentsClient) ListForScope(ctx context.Context, scope string, filter string, tenantID 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, tenantID) + 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 + } + if result.ralr.hasNextLink() && result.ralr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListForScopePreparer prepares the ListForScope request. +func (client RoleAssignmentsClient) ListForScopePreparer(ctx context.Context, scope string, filter string, tenantID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = filter + } + if len(tenantID) > 0 { + queryParameters["tenantId"] = autorest.Encode("query", tenantID) + } + + 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 client.Send(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, + 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, tenantID 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, tenantID) + return +} + +// ListForSubscription list all role assignments that apply to a 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. +// tenantID - tenant ID for cross-tenant request +func (client RoleAssignmentsClient) ListForSubscription(ctx context.Context, filter string, tenantID string) (result RoleAssignmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListForSubscription") + defer func() { + sc := -1 + if result.ralr.Response.Response != nil { + sc = result.ralr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("authorization.RoleAssignmentsClient", "ListForSubscription", err.Error()) + } + + result.fn = client.listForSubscriptionNextResults + req, err := client.ListForSubscriptionPreparer(ctx, filter, tenantID) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForSubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListForSubscriptionSender(req) + if err != nil { + result.ralr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForSubscription", resp, "Failure sending request") + return + } + + result.ralr, err = client.ListForSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForSubscription", resp, "Failure responding to request") + return + } + if result.ralr.hasNextLink() && result.ralr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListForSubscriptionPreparer prepares the ListForSubscription request. +func (client RoleAssignmentsClient) ListForSubscriptionPreparer(ctx context.Context, filter string, tenantID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = filter + } + if len(tenantID) > 0 { + queryParameters["tenantId"] = autorest.Encode("query", tenantID) + } + + 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)) +} + +// ListForSubscriptionSender sends the ListForSubscription request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentsClient) ListForSubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListForSubscriptionResponder handles the response to the ListForSubscription request. The method always +// closes the http.Response Body. +func (client RoleAssignmentsClient) ListForSubscriptionResponder(resp *http.Response) (result RoleAssignmentListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listForSubscriptionNextResults retrieves the next set of results, if any. +func (client RoleAssignmentsClient) listForSubscriptionNextResults(ctx context.Context, lastResults RoleAssignmentListResult) (result RoleAssignmentListResult, err error) { + req, err := lastResults.roleAssignmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForSubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListForSubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForSubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListForSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForSubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListForSubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client RoleAssignmentsClient) ListForSubscriptionComplete(ctx context.Context, filter string, tenantID string) (result RoleAssignmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListForSubscription") + 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.ListForSubscription(ctx, filter, tenantID) + return +} + +// Validate validate a role assignment create or update operation by scope and name. +// Parameters: +// scope - the scope of the operation or resource. Valid scopes are: subscription (format: +// '/subscriptions/{subscriptionId}'), resource group (format: +// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: +// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' +// roleAssignmentName - the name of the role assignment. It can be any valid GUID. +// parameters - parameters for the role assignment. +func (client RoleAssignmentsClient) Validate(ctx context.Context, scope string, roleAssignmentName string, parameters RoleAssignmentCreateParameters) (result ValidationResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.Validate") + 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", "Validate", err.Error()) + } + + req, err := client.ValidatePreparer(ctx, scope, roleAssignmentName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Validate", nil, "Failure preparing request") + return + } + + resp, err := client.ValidateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Validate", resp, "Failure sending request") + return + } + + result, err = client.ValidateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Validate", resp, "Failure responding to request") + return + } + + return +} + +// ValidatePreparer prepares the Validate request. +func (client RoleAssignmentsClient) ValidatePreparer(ctx context.Context, scope string, roleAssignmentName string, parameters RoleAssignmentCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleAssignmentName": roleAssignmentName, + "scope": scope, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ValidateSender sends the Validate request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentsClient) ValidateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ValidateResponder handles the response to the Validate request. The method always +// closes the http.Response Body. +func (client RoleAssignmentsClient) ValidateResponder(resp *http.Response) (result ValidationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ValidateByID validate a role assignment create or update operation by ID. +// Parameters: +// roleAssignmentID - the fully qualified ID of the role assignment including scope, resource name, and +// resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. +// Example: +// /subscriptions//resourcegroups//providers/Microsoft.Authorization/roleAssignments/ +// parameters - parameters for the role assignment. +func (client RoleAssignmentsClient) ValidateByID(ctx context.Context, roleAssignmentID string, parameters RoleAssignmentCreateParameters) (result ValidationResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ValidateByID") + 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", "ValidateByID", err.Error()) + } + + req, err := client.ValidateByIDPreparer(ctx, roleAssignmentID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ValidateByID", nil, "Failure preparing request") + return + } + + resp, err := client.ValidateByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ValidateByID", resp, "Failure sending request") + return + } + + result, err = client.ValidateByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ValidateByID", resp, "Failure responding to request") + return + } + + return +} + +// ValidateByIDPreparer prepares the ValidateByID request. +func (client RoleAssignmentsClient) ValidateByIDPreparer(ctx context.Context, roleAssignmentID string, parameters RoleAssignmentCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleAssignmentId": roleAssignmentID, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{roleAssignmentId}/validate", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ValidateByIDSender sends the ValidateByID request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentsClient) ValidateByIDSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ValidateByIDResponder handles the response to the ValidateByID request. The method always +// closes the http.Response Body. +func (client RoleAssignmentsClient) ValidateByIDResponder(resp *http.Response) (result ValidationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleassignmentscheduleinstances.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleassignmentscheduleinstances.go new file mode 100644 index 000000000000..2622b835caaf --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleassignmentscheduleinstances.go @@ -0,0 +1,232 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RoleAssignmentScheduleInstancesClient is the client for the RoleAssignmentScheduleInstances methods of the +// Authorization service. +type RoleAssignmentScheduleInstancesClient struct { + BaseClient +} + +// NewRoleAssignmentScheduleInstancesClient creates an instance of the RoleAssignmentScheduleInstancesClient client. +func NewRoleAssignmentScheduleInstancesClient(subscriptionID string) RoleAssignmentScheduleInstancesClient { + return NewRoleAssignmentScheduleInstancesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRoleAssignmentScheduleInstancesClientWithBaseURI creates an instance of the RoleAssignmentScheduleInstancesClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewRoleAssignmentScheduleInstancesClientWithBaseURI(baseURI string, subscriptionID string) RoleAssignmentScheduleInstancesClient { + return RoleAssignmentScheduleInstancesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets the specified role assignment schedule instance. +// Parameters: +// scope - the scope of the role assignments schedules. +// roleAssignmentScheduleInstanceName - the name (hash of schedule name + time) of the role assignment schedule +// to get. +func (client RoleAssignmentScheduleInstancesClient) Get(ctx context.Context, scope string, roleAssignmentScheduleInstanceName string) (result RoleAssignmentScheduleInstance, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentScheduleInstancesClient.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, roleAssignmentScheduleInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentScheduleInstancesClient", "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.RoleAssignmentScheduleInstancesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentScheduleInstancesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RoleAssignmentScheduleInstancesClient) GetPreparer(ctx context.Context, scope string, roleAssignmentScheduleInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleAssignmentScheduleInstanceName": autorest.Encode("path", roleAssignmentScheduleInstanceName), + "scope": scope, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}", 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 RoleAssignmentScheduleInstancesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(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 RoleAssignmentScheduleInstancesClient) GetResponder(resp *http.Response) (result RoleAssignmentScheduleInstance, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListForScope gets role assignment schedule instances of a role assignment schedule. +// Parameters: +// scope - the scope of the role assignment schedule. +// filter - the filter to apply on the operation. Use $filter=atScope() to return all role assignment schedules +// at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedules at, above or +// below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role +// assignment schedule instances for the user. Use $filter=asTarget() to return all role assignment schedule +// instances created for the current user. +func (client RoleAssignmentScheduleInstancesClient) ListForScope(ctx context.Context, scope string, filter string) (result RoleAssignmentScheduleInstanceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentScheduleInstancesClient.ListForScope") + defer func() { + sc := -1 + if result.rasilr.Response.Response != nil { + sc = result.rasilr.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.RoleAssignmentScheduleInstancesClient", "ListForScope", nil, "Failure preparing request") + return + } + + resp, err := client.ListForScopeSender(req) + if err != nil { + result.rasilr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentScheduleInstancesClient", "ListForScope", resp, "Failure sending request") + return + } + + result.rasilr, err = client.ListForScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentScheduleInstancesClient", "ListForScope", resp, "Failure responding to request") + return + } + if result.rasilr.hasNextLink() && result.rasilr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListForScopePreparer prepares the ListForScope request. +func (client RoleAssignmentScheduleInstancesClient) ListForScopePreparer(ctx context.Context, scope string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2020-10-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/roleAssignmentScheduleInstances", 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 RoleAssignmentScheduleInstancesClient) ListForScopeSender(req *http.Request) (*http.Response, error) { + return client.Send(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 RoleAssignmentScheduleInstancesClient) ListForScopeResponder(resp *http.Response) (result RoleAssignmentScheduleInstanceListResult, err error) { + err = autorest.Respond( + resp, + 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 RoleAssignmentScheduleInstancesClient) listForScopeNextResults(ctx context.Context, lastResults RoleAssignmentScheduleInstanceListResult) (result RoleAssignmentScheduleInstanceListResult, err error) { + req, err := lastResults.roleAssignmentScheduleInstanceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentScheduleInstancesClient", "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.RoleAssignmentScheduleInstancesClient", "listForScopeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListForScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentScheduleInstancesClient", "listForScopeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListForScopeComplete enumerates all values, automatically crossing page boundaries as required. +func (client RoleAssignmentScheduleInstancesClient) ListForScopeComplete(ctx context.Context, scope string, filter string) (result RoleAssignmentScheduleInstanceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentScheduleInstancesClient.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/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleassignmentschedulerequests.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleassignmentschedulerequests.go new file mode 100644 index 000000000000..cc0a4d943eb1 --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleassignmentschedulerequests.go @@ -0,0 +1,404 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RoleAssignmentScheduleRequestsClient is the client for the RoleAssignmentScheduleRequests methods of the +// Authorization service. +type RoleAssignmentScheduleRequestsClient struct { + BaseClient +} + +// NewRoleAssignmentScheduleRequestsClient creates an instance of the RoleAssignmentScheduleRequestsClient client. +func NewRoleAssignmentScheduleRequestsClient(subscriptionID string) RoleAssignmentScheduleRequestsClient { + return NewRoleAssignmentScheduleRequestsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRoleAssignmentScheduleRequestsClientWithBaseURI creates an instance of the RoleAssignmentScheduleRequestsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewRoleAssignmentScheduleRequestsClientWithBaseURI(baseURI string, subscriptionID string) RoleAssignmentScheduleRequestsClient { + return RoleAssignmentScheduleRequestsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Cancel cancels a pending role assignment schedule request. +// Parameters: +// scope - the scope of the role assignment request to cancel. +// roleAssignmentScheduleRequestName - the name of the role assignment request to cancel. +func (client RoleAssignmentScheduleRequestsClient) Cancel(ctx context.Context, scope string, roleAssignmentScheduleRequestName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentScheduleRequestsClient.Cancel") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CancelPreparer(ctx, scope, roleAssignmentScheduleRequestName) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentScheduleRequestsClient", "Cancel", nil, "Failure preparing request") + return + } + + resp, err := client.CancelSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentScheduleRequestsClient", "Cancel", resp, "Failure sending request") + return + } + + result, err = client.CancelResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentScheduleRequestsClient", "Cancel", resp, "Failure responding to request") + return + } + + return +} + +// CancelPreparer prepares the Cancel request. +func (client RoleAssignmentScheduleRequestsClient) CancelPreparer(ctx context.Context, scope string, roleAssignmentScheduleRequestName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleAssignmentScheduleRequestName": autorest.Encode("path", roleAssignmentScheduleRequestName), + "scope": scope, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CancelSender sends the Cancel request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentScheduleRequestsClient) CancelSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CancelResponder handles the response to the Cancel request. The method always +// closes the http.Response Body. +func (client RoleAssignmentScheduleRequestsClient) CancelResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Create creates a role assignment schedule request. +// Parameters: +// scope - the scope of the role assignment schedule request to create. The scope can be any REST resource +// instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a +// subscription, +// '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for +// a resource group, and +// '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' +// for a resource. +// roleAssignmentScheduleRequestName - a GUID for the role assignment to create. The name must be unique and +// different for each role assignment. +// parameters - parameters for the role assignment schedule request. +func (client RoleAssignmentScheduleRequestsClient) Create(ctx context.Context, scope string, roleAssignmentScheduleRequestName string, parameters RoleAssignmentScheduleRequest) (result RoleAssignmentScheduleRequest, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentScheduleRequestsClient.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.RoleAssignmentScheduleRequestProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.RoleAssignmentScheduleRequestProperties.RoleDefinitionID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.RoleAssignmentScheduleRequestProperties.PrincipalID", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("authorization.RoleAssignmentScheduleRequestsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, scope, roleAssignmentScheduleRequestName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentScheduleRequestsClient", "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.RoleAssignmentScheduleRequestsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentScheduleRequestsClient", "Create", resp, "Failure responding to request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client RoleAssignmentScheduleRequestsClient) CreatePreparer(ctx context.Context, scope string, roleAssignmentScheduleRequestName string, parameters RoleAssignmentScheduleRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleAssignmentScheduleRequestName": autorest.Encode("path", roleAssignmentScheduleRequestName), + "scope": scope, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.ID = nil + parameters.Name = nil + parameters.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}", 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 RoleAssignmentScheduleRequestsClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(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 RoleAssignmentScheduleRequestsClient) CreateResponder(resp *http.Response) (result RoleAssignmentScheduleRequest, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get the specified role assignment schedule request. +// Parameters: +// scope - the scope of the role assignment schedule request. +// roleAssignmentScheduleRequestName - the name (guid) of the role assignment schedule request to get. +func (client RoleAssignmentScheduleRequestsClient) Get(ctx context.Context, scope string, roleAssignmentScheduleRequestName string) (result RoleAssignmentScheduleRequest, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentScheduleRequestsClient.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, roleAssignmentScheduleRequestName) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentScheduleRequestsClient", "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.RoleAssignmentScheduleRequestsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentScheduleRequestsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RoleAssignmentScheduleRequestsClient) GetPreparer(ctx context.Context, scope string, roleAssignmentScheduleRequestName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleAssignmentScheduleRequestName": autorest.Encode("path", roleAssignmentScheduleRequestName), + "scope": scope, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}", 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 RoleAssignmentScheduleRequestsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(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 RoleAssignmentScheduleRequestsClient) GetResponder(resp *http.Response) (result RoleAssignmentScheduleRequest, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListForScope gets role assignment schedule requests for a scope. +// Parameters: +// scope - the scope of the role assignments schedule requests. +// filter - the filter to apply on the operation. Use $filter=atScope() to return all role assignment schedule +// requests at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedule +// requests at, above or below the scope for the specified principal. Use $filter=asRequestor() to return all +// role assignment schedule requests requested by the current user. Use $filter=asTarget() to return all role +// assignment schedule requests created for the current user. Use $filter=asApprover() to return all role +// assignment schedule requests where the current user is an approver. +func (client RoleAssignmentScheduleRequestsClient) ListForScope(ctx context.Context, scope string, filter string) (result RoleAssignmentScheduleRequestListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentScheduleRequestsClient.ListForScope") + defer func() { + sc := -1 + if result.rasrlr.Response.Response != nil { + sc = result.rasrlr.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.RoleAssignmentScheduleRequestsClient", "ListForScope", nil, "Failure preparing request") + return + } + + resp, err := client.ListForScopeSender(req) + if err != nil { + result.rasrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentScheduleRequestsClient", "ListForScope", resp, "Failure sending request") + return + } + + result.rasrlr, err = client.ListForScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentScheduleRequestsClient", "ListForScope", resp, "Failure responding to request") + return + } + if result.rasrlr.hasNextLink() && result.rasrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListForScopePreparer prepares the ListForScope request. +func (client RoleAssignmentScheduleRequestsClient) ListForScopePreparer(ctx context.Context, scope string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2020-10-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/roleAssignmentScheduleRequests", 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 RoleAssignmentScheduleRequestsClient) ListForScopeSender(req *http.Request) (*http.Response, error) { + return client.Send(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 RoleAssignmentScheduleRequestsClient) ListForScopeResponder(resp *http.Response) (result RoleAssignmentScheduleRequestListResult, err error) { + err = autorest.Respond( + resp, + 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 RoleAssignmentScheduleRequestsClient) listForScopeNextResults(ctx context.Context, lastResults RoleAssignmentScheduleRequestListResult) (result RoleAssignmentScheduleRequestListResult, err error) { + req, err := lastResults.roleAssignmentScheduleRequestListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentScheduleRequestsClient", "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.RoleAssignmentScheduleRequestsClient", "listForScopeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListForScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentScheduleRequestsClient", "listForScopeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListForScopeComplete enumerates all values, automatically crossing page boundaries as required. +func (client RoleAssignmentScheduleRequestsClient) ListForScopeComplete(ctx context.Context, scope string, filter string) (result RoleAssignmentScheduleRequestListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentScheduleRequestsClient.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/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleassignmentschedules.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleassignmentschedules.go new file mode 100644 index 000000000000..7e46ba24f7a9 --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleassignmentschedules.go @@ -0,0 +1,230 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RoleAssignmentSchedulesClient is the client for the RoleAssignmentSchedules methods of the Authorization service. +type RoleAssignmentSchedulesClient struct { + BaseClient +} + +// NewRoleAssignmentSchedulesClient creates an instance of the RoleAssignmentSchedulesClient client. +func NewRoleAssignmentSchedulesClient(subscriptionID string) RoleAssignmentSchedulesClient { + return NewRoleAssignmentSchedulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRoleAssignmentSchedulesClientWithBaseURI creates an instance of the RoleAssignmentSchedulesClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewRoleAssignmentSchedulesClientWithBaseURI(baseURI string, subscriptionID string) RoleAssignmentSchedulesClient { + return RoleAssignmentSchedulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the specified role assignment schedule for a resource scope +// Parameters: +// scope - the scope of the role assignment schedule. +// roleAssignmentScheduleName - the name (guid) of the role assignment schedule to get. +func (client RoleAssignmentSchedulesClient) Get(ctx context.Context, scope string, roleAssignmentScheduleName string) (result RoleAssignmentSchedule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentSchedulesClient.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, roleAssignmentScheduleName) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentSchedulesClient", "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.RoleAssignmentSchedulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentSchedulesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RoleAssignmentSchedulesClient) GetPreparer(ctx context.Context, scope string, roleAssignmentScheduleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleAssignmentScheduleName": autorest.Encode("path", roleAssignmentScheduleName), + "scope": scope, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}", 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 RoleAssignmentSchedulesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(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 RoleAssignmentSchedulesClient) GetResponder(resp *http.Response) (result RoleAssignmentSchedule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListForScope gets role assignment schedules for a resource scope. +// Parameters: +// scope - the scope of the role assignments schedules. +// filter - the filter to apply on the operation. Use $filter=atScope() to return all role assignment schedules +// at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedules at, above or +// below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role +// assignment schedules for the current user. Use $filter=asTarget() to return all role assignment schedules +// created for the current user. +func (client RoleAssignmentSchedulesClient) ListForScope(ctx context.Context, scope string, filter string) (result RoleAssignmentScheduleListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentSchedulesClient.ListForScope") + defer func() { + sc := -1 + if result.raslr.Response.Response != nil { + sc = result.raslr.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.RoleAssignmentSchedulesClient", "ListForScope", nil, "Failure preparing request") + return + } + + resp, err := client.ListForScopeSender(req) + if err != nil { + result.raslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentSchedulesClient", "ListForScope", resp, "Failure sending request") + return + } + + result.raslr, err = client.ListForScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentSchedulesClient", "ListForScope", resp, "Failure responding to request") + return + } + if result.raslr.hasNextLink() && result.raslr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListForScopePreparer prepares the ListForScope request. +func (client RoleAssignmentSchedulesClient) ListForScopePreparer(ctx context.Context, scope string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2020-10-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/roleAssignmentSchedules", 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 RoleAssignmentSchedulesClient) ListForScopeSender(req *http.Request) (*http.Response, error) { + return client.Send(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 RoleAssignmentSchedulesClient) ListForScopeResponder(resp *http.Response) (result RoleAssignmentScheduleListResult, err error) { + err = autorest.Respond( + resp, + 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 RoleAssignmentSchedulesClient) listForScopeNextResults(ctx context.Context, lastResults RoleAssignmentScheduleListResult) (result RoleAssignmentScheduleListResult, err error) { + req, err := lastResults.roleAssignmentScheduleListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentSchedulesClient", "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.RoleAssignmentSchedulesClient", "listForScopeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListForScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentSchedulesClient", "listForScopeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListForScopeComplete enumerates all values, automatically crossing page boundaries as required. +func (client RoleAssignmentSchedulesClient) ListForScopeComplete(ctx context.Context, scope string, filter string) (result RoleAssignmentScheduleListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentSchedulesClient.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/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roledefinitions.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roledefinitions.go new file mode 100644 index 000000000000..445a59445e3d --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roledefinitions.go @@ -0,0 +1,458 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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 using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +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 + } + + 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 client.Send(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, + 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 + } + + 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + 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 + } + + 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 client.Send(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, + 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 + } + + 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 client.Send(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, + 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 + } + if result.rdlr.hasNextLink() && result.rdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RoleDefinitionsClient) ListResponder(resp *http.Response) (result RoleDefinitionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client 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/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleeligibilityscheduleinstances.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleeligibilityscheduleinstances.go new file mode 100644 index 000000000000..e9bf11d29748 --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleeligibilityscheduleinstances.go @@ -0,0 +1,232 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RoleEligibilityScheduleInstancesClient is the client for the RoleEligibilityScheduleInstances methods of the +// Authorization service. +type RoleEligibilityScheduleInstancesClient struct { + BaseClient +} + +// NewRoleEligibilityScheduleInstancesClient creates an instance of the RoleEligibilityScheduleInstancesClient client. +func NewRoleEligibilityScheduleInstancesClient(subscriptionID string) RoleEligibilityScheduleInstancesClient { + return NewRoleEligibilityScheduleInstancesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRoleEligibilityScheduleInstancesClientWithBaseURI creates an instance of the +// RoleEligibilityScheduleInstancesClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewRoleEligibilityScheduleInstancesClientWithBaseURI(baseURI string, subscriptionID string) RoleEligibilityScheduleInstancesClient { + return RoleEligibilityScheduleInstancesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets the specified role eligibility schedule instance. +// Parameters: +// scope - the scope of the role eligibility schedules. +// roleEligibilityScheduleInstanceName - the name (hash of schedule name + time) of the role eligibility +// schedule to get. +func (client RoleEligibilityScheduleInstancesClient) Get(ctx context.Context, scope string, roleEligibilityScheduleInstanceName string) (result RoleEligibilityScheduleInstance, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleEligibilityScheduleInstancesClient.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, roleEligibilityScheduleInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleEligibilityScheduleInstancesClient", "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.RoleEligibilityScheduleInstancesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleEligibilityScheduleInstancesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RoleEligibilityScheduleInstancesClient) GetPreparer(ctx context.Context, scope string, roleEligibilityScheduleInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleEligibilityScheduleInstanceName": autorest.Encode("path", roleEligibilityScheduleInstanceName), + "scope": scope, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}", 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 RoleEligibilityScheduleInstancesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(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 RoleEligibilityScheduleInstancesClient) GetResponder(resp *http.Response) (result RoleEligibilityScheduleInstance, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListForScope gets role eligibility schedule instances of a role eligibility schedule. +// Parameters: +// scope - the scope of the role eligibility schedule. +// filter - the filter to apply on the operation. Use $filter=atScope() to return all role assignment schedules +// at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedules at, above or +// below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role +// eligibility schedules for the user. Use $filter=asTarget() to return all role eligibility schedules created +// for the current user. +func (client RoleEligibilityScheduleInstancesClient) ListForScope(ctx context.Context, scope string, filter string) (result RoleEligibilityScheduleInstanceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleEligibilityScheduleInstancesClient.ListForScope") + defer func() { + sc := -1 + if result.resilr.Response.Response != nil { + sc = result.resilr.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.RoleEligibilityScheduleInstancesClient", "ListForScope", nil, "Failure preparing request") + return + } + + resp, err := client.ListForScopeSender(req) + if err != nil { + result.resilr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleEligibilityScheduleInstancesClient", "ListForScope", resp, "Failure sending request") + return + } + + result.resilr, err = client.ListForScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleEligibilityScheduleInstancesClient", "ListForScope", resp, "Failure responding to request") + return + } + if result.resilr.hasNextLink() && result.resilr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListForScopePreparer prepares the ListForScope request. +func (client RoleEligibilityScheduleInstancesClient) ListForScopePreparer(ctx context.Context, scope string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2020-10-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/roleEligibilityScheduleInstances", 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 RoleEligibilityScheduleInstancesClient) ListForScopeSender(req *http.Request) (*http.Response, error) { + return client.Send(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 RoleEligibilityScheduleInstancesClient) ListForScopeResponder(resp *http.Response) (result RoleEligibilityScheduleInstanceListResult, err error) { + err = autorest.Respond( + resp, + 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 RoleEligibilityScheduleInstancesClient) listForScopeNextResults(ctx context.Context, lastResults RoleEligibilityScheduleInstanceListResult) (result RoleEligibilityScheduleInstanceListResult, err error) { + req, err := lastResults.roleEligibilityScheduleInstanceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.RoleEligibilityScheduleInstancesClient", "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.RoleEligibilityScheduleInstancesClient", "listForScopeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListForScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleEligibilityScheduleInstancesClient", "listForScopeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListForScopeComplete enumerates all values, automatically crossing page boundaries as required. +func (client RoleEligibilityScheduleInstancesClient) ListForScopeComplete(ctx context.Context, scope string, filter string) (result RoleEligibilityScheduleInstanceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleEligibilityScheduleInstancesClient.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/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleeligibilityschedulerequests.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleeligibilityschedulerequests.go new file mode 100644 index 000000000000..9a2ab95ffb5b --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleeligibilityschedulerequests.go @@ -0,0 +1,403 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RoleEligibilityScheduleRequestsClient is the client for the RoleEligibilityScheduleRequests methods of the +// Authorization service. +type RoleEligibilityScheduleRequestsClient struct { + BaseClient +} + +// NewRoleEligibilityScheduleRequestsClient creates an instance of the RoleEligibilityScheduleRequestsClient client. +func NewRoleEligibilityScheduleRequestsClient(subscriptionID string) RoleEligibilityScheduleRequestsClient { + return NewRoleEligibilityScheduleRequestsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRoleEligibilityScheduleRequestsClientWithBaseURI creates an instance of the RoleEligibilityScheduleRequestsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewRoleEligibilityScheduleRequestsClientWithBaseURI(baseURI string, subscriptionID string) RoleEligibilityScheduleRequestsClient { + return RoleEligibilityScheduleRequestsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Cancel cancels a pending role eligibility schedule request. +// Parameters: +// scope - the scope of the role eligibility request to cancel. +// roleEligibilityScheduleRequestName - the name of the role eligibility request to cancel. +func (client RoleEligibilityScheduleRequestsClient) Cancel(ctx context.Context, scope string, roleEligibilityScheduleRequestName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleEligibilityScheduleRequestsClient.Cancel") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CancelPreparer(ctx, scope, roleEligibilityScheduleRequestName) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleEligibilityScheduleRequestsClient", "Cancel", nil, "Failure preparing request") + return + } + + resp, err := client.CancelSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "authorization.RoleEligibilityScheduleRequestsClient", "Cancel", resp, "Failure sending request") + return + } + + result, err = client.CancelResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleEligibilityScheduleRequestsClient", "Cancel", resp, "Failure responding to request") + return + } + + return +} + +// CancelPreparer prepares the Cancel request. +func (client RoleEligibilityScheduleRequestsClient) CancelPreparer(ctx context.Context, scope string, roleEligibilityScheduleRequestName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleEligibilityScheduleRequestName": autorest.Encode("path", roleEligibilityScheduleRequestName), + "scope": scope, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CancelSender sends the Cancel request. The method will close the +// http.Response Body if it receives an error. +func (client RoleEligibilityScheduleRequestsClient) CancelSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CancelResponder handles the response to the Cancel request. The method always +// closes the http.Response Body. +func (client RoleEligibilityScheduleRequestsClient) CancelResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Create creates a role eligibility schedule request. +// Parameters: +// scope - the scope of the role eligibility schedule request to create. The scope can be any REST resource +// instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a +// subscription, +// '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for +// a resource group, and +// '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' +// for a resource. +// roleEligibilityScheduleRequestName - the name of the role eligibility to create. It can be any valid GUID. +// parameters - parameters for the role eligibility schedule request. +func (client RoleEligibilityScheduleRequestsClient) Create(ctx context.Context, scope string, roleEligibilityScheduleRequestName string, parameters RoleEligibilityScheduleRequest) (result RoleEligibilityScheduleRequest, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleEligibilityScheduleRequestsClient.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.RoleEligibilityScheduleRequestProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.RoleEligibilityScheduleRequestProperties.RoleDefinitionID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.RoleEligibilityScheduleRequestProperties.PrincipalID", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("authorization.RoleEligibilityScheduleRequestsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, scope, roleEligibilityScheduleRequestName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleEligibilityScheduleRequestsClient", "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.RoleEligibilityScheduleRequestsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleEligibilityScheduleRequestsClient", "Create", resp, "Failure responding to request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client RoleEligibilityScheduleRequestsClient) CreatePreparer(ctx context.Context, scope string, roleEligibilityScheduleRequestName string, parameters RoleEligibilityScheduleRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleEligibilityScheduleRequestName": autorest.Encode("path", roleEligibilityScheduleRequestName), + "scope": scope, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.ID = nil + parameters.Name = nil + parameters.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}", 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 RoleEligibilityScheduleRequestsClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(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 RoleEligibilityScheduleRequestsClient) CreateResponder(resp *http.Response) (result RoleEligibilityScheduleRequest, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get the specified role eligibility schedule request. +// Parameters: +// scope - the scope of the role eligibility schedule request. +// roleEligibilityScheduleRequestName - the name (guid) of the role eligibility schedule request to get. +func (client RoleEligibilityScheduleRequestsClient) Get(ctx context.Context, scope string, roleEligibilityScheduleRequestName string) (result RoleEligibilityScheduleRequest, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleEligibilityScheduleRequestsClient.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, roleEligibilityScheduleRequestName) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleEligibilityScheduleRequestsClient", "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.RoleEligibilityScheduleRequestsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleEligibilityScheduleRequestsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RoleEligibilityScheduleRequestsClient) GetPreparer(ctx context.Context, scope string, roleEligibilityScheduleRequestName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleEligibilityScheduleRequestName": autorest.Encode("path", roleEligibilityScheduleRequestName), + "scope": scope, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}", 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 RoleEligibilityScheduleRequestsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(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 RoleEligibilityScheduleRequestsClient) GetResponder(resp *http.Response) (result RoleEligibilityScheduleRequest, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListForScope gets role eligibility schedule requests for a scope. +// Parameters: +// scope - the scope of the role eligibility schedule requests. +// filter - the filter to apply on the operation. Use $filter=atScope() to return all role eligibility schedule +// requests at or above the scope. Use $filter=principalId eq {id} to return all role eligibility schedule +// requests at, above or below the scope for the specified principal. Use $filter=asRequestor() to return all +// role eligibility schedule requests requested by the current user. Use $filter=asTarget() to return all role +// eligibility schedule requests created for the current user. Use $filter=asApprover() to return all role +// eligibility schedule requests where the current user is an approver. +func (client RoleEligibilityScheduleRequestsClient) ListForScope(ctx context.Context, scope string, filter string) (result RoleEligibilityScheduleRequestListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleEligibilityScheduleRequestsClient.ListForScope") + defer func() { + sc := -1 + if result.resrlr.Response.Response != nil { + sc = result.resrlr.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.RoleEligibilityScheduleRequestsClient", "ListForScope", nil, "Failure preparing request") + return + } + + resp, err := client.ListForScopeSender(req) + if err != nil { + result.resrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleEligibilityScheduleRequestsClient", "ListForScope", resp, "Failure sending request") + return + } + + result.resrlr, err = client.ListForScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleEligibilityScheduleRequestsClient", "ListForScope", resp, "Failure responding to request") + return + } + if result.resrlr.hasNextLink() && result.resrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListForScopePreparer prepares the ListForScope request. +func (client RoleEligibilityScheduleRequestsClient) ListForScopePreparer(ctx context.Context, scope string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2020-10-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/roleEligibilityScheduleRequests", 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 RoleEligibilityScheduleRequestsClient) ListForScopeSender(req *http.Request) (*http.Response, error) { + return client.Send(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 RoleEligibilityScheduleRequestsClient) ListForScopeResponder(resp *http.Response) (result RoleEligibilityScheduleRequestListResult, err error) { + err = autorest.Respond( + resp, + 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 RoleEligibilityScheduleRequestsClient) listForScopeNextResults(ctx context.Context, lastResults RoleEligibilityScheduleRequestListResult) (result RoleEligibilityScheduleRequestListResult, err error) { + req, err := lastResults.roleEligibilityScheduleRequestListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.RoleEligibilityScheduleRequestsClient", "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.RoleEligibilityScheduleRequestsClient", "listForScopeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListForScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleEligibilityScheduleRequestsClient", "listForScopeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListForScopeComplete enumerates all values, automatically crossing page boundaries as required. +func (client RoleEligibilityScheduleRequestsClient) ListForScopeComplete(ctx context.Context, scope string, filter string) (result RoleEligibilityScheduleRequestListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleEligibilityScheduleRequestsClient.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/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleeligibilityschedules.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleeligibilityschedules.go new file mode 100644 index 000000000000..704d5d6f406c --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/roleeligibilityschedules.go @@ -0,0 +1,230 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RoleEligibilitySchedulesClient is the client for the RoleEligibilitySchedules methods of the Authorization service. +type RoleEligibilitySchedulesClient struct { + BaseClient +} + +// NewRoleEligibilitySchedulesClient creates an instance of the RoleEligibilitySchedulesClient client. +func NewRoleEligibilitySchedulesClient(subscriptionID string) RoleEligibilitySchedulesClient { + return NewRoleEligibilitySchedulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRoleEligibilitySchedulesClientWithBaseURI creates an instance of the RoleEligibilitySchedulesClient client using +// a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewRoleEligibilitySchedulesClientWithBaseURI(baseURI string, subscriptionID string) RoleEligibilitySchedulesClient { + return RoleEligibilitySchedulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the specified role eligibility schedule for a resource scope +// Parameters: +// scope - the scope of the role eligibility schedule. +// roleEligibilityScheduleName - the name (guid) of the role eligibility schedule to get. +func (client RoleEligibilitySchedulesClient) Get(ctx context.Context, scope string, roleEligibilityScheduleName string) (result RoleEligibilitySchedule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleEligibilitySchedulesClient.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, roleEligibilityScheduleName) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleEligibilitySchedulesClient", "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.RoleEligibilitySchedulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleEligibilitySchedulesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RoleEligibilitySchedulesClient) GetPreparer(ctx context.Context, scope string, roleEligibilityScheduleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleEligibilityScheduleName": autorest.Encode("path", roleEligibilityScheduleName), + "scope": scope, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}", 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 RoleEligibilitySchedulesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(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 RoleEligibilitySchedulesClient) GetResponder(resp *http.Response) (result RoleEligibilitySchedule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListForScope gets role eligibility schedules for a resource scope. +// Parameters: +// scope - the scope of the role eligibility schedules. +// filter - the filter to apply on the operation. Use $filter=atScope() to return all role eligibility +// schedules at or above the scope. Use $filter=principalId eq {id} to return all role eligibility schedules +// at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all +// role eligibility schedules for the user. Use $filter=asTarget() to return all role eligibility schedules +// created for the current user. +func (client RoleEligibilitySchedulesClient) ListForScope(ctx context.Context, scope string, filter string) (result RoleEligibilityScheduleListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleEligibilitySchedulesClient.ListForScope") + defer func() { + sc := -1 + if result.reslr.Response.Response != nil { + sc = result.reslr.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.RoleEligibilitySchedulesClient", "ListForScope", nil, "Failure preparing request") + return + } + + resp, err := client.ListForScopeSender(req) + if err != nil { + result.reslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleEligibilitySchedulesClient", "ListForScope", resp, "Failure sending request") + return + } + + result.reslr, err = client.ListForScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleEligibilitySchedulesClient", "ListForScope", resp, "Failure responding to request") + return + } + if result.reslr.hasNextLink() && result.reslr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListForScopePreparer prepares the ListForScope request. +func (client RoleEligibilitySchedulesClient) ListForScopePreparer(ctx context.Context, scope string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2020-10-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/roleEligibilitySchedules", 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 RoleEligibilitySchedulesClient) ListForScopeSender(req *http.Request) (*http.Response, error) { + return client.Send(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 RoleEligibilitySchedulesClient) ListForScopeResponder(resp *http.Response) (result RoleEligibilityScheduleListResult, err error) { + err = autorest.Respond( + resp, + 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 RoleEligibilitySchedulesClient) listForScopeNextResults(ctx context.Context, lastResults RoleEligibilityScheduleListResult) (result RoleEligibilityScheduleListResult, err error) { + req, err := lastResults.roleEligibilityScheduleListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.RoleEligibilitySchedulesClient", "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.RoleEligibilitySchedulesClient", "listForScopeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListForScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleEligibilitySchedulesClient", "listForScopeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListForScopeComplete enumerates all values, automatically crossing page boundaries as required. +func (client RoleEligibilitySchedulesClient) ListForScopeComplete(ctx context.Context, scope string, filter string) (result RoleEligibilityScheduleListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleEligibilitySchedulesClient.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/services/preview/authorization/mgmt/2020-10-01-preview/authorization/rolemanagementpolicies.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/rolemanagementpolicies.go new file mode 100644 index 000000000000..a30fc19f122b --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/rolemanagementpolicies.go @@ -0,0 +1,377 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RoleManagementPoliciesClient is the client for the RoleManagementPolicies methods of the Authorization service. +type RoleManagementPoliciesClient struct { + BaseClient +} + +// NewRoleManagementPoliciesClient creates an instance of the RoleManagementPoliciesClient client. +func NewRoleManagementPoliciesClient(subscriptionID string) RoleManagementPoliciesClient { + return NewRoleManagementPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRoleManagementPoliciesClientWithBaseURI creates an instance of the RoleManagementPoliciesClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewRoleManagementPoliciesClientWithBaseURI(baseURI string, subscriptionID string) RoleManagementPoliciesClient { + return RoleManagementPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete delete a role management policy +// Parameters: +// scope - the scope of the role management policy to upsert. +// roleManagementPolicyName - the name (guid) of the role management policy to upsert. +func (client RoleManagementPoliciesClient) Delete(ctx context.Context, scope string, roleManagementPolicyName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleManagementPoliciesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, scope, roleManagementPolicyName) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPoliciesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPoliciesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPoliciesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client RoleManagementPoliciesClient) DeletePreparer(ctx context.Context, scope string, roleManagementPolicyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleManagementPolicyName": autorest.Encode("path", roleManagementPolicyName), + "scope": scope, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}", 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 RoleManagementPoliciesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(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 RoleManagementPoliciesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the specified role management policy for a resource scope +// Parameters: +// scope - the scope of the role management policy. +// roleManagementPolicyName - the name (guid) of the role management policy to get. +func (client RoleManagementPoliciesClient) Get(ctx context.Context, scope string, roleManagementPolicyName string) (result RoleManagementPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleManagementPoliciesClient.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, roleManagementPolicyName) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPoliciesClient", "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.RoleManagementPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RoleManagementPoliciesClient) GetPreparer(ctx context.Context, scope string, roleManagementPolicyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleManagementPolicyName": autorest.Encode("path", roleManagementPolicyName), + "scope": scope, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}", 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 RoleManagementPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(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 RoleManagementPoliciesClient) GetResponder(resp *http.Response) (result RoleManagementPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListForScope gets role management policies for a resource scope. +// Parameters: +// scope - the scope of the role management policy. +func (client RoleManagementPoliciesClient) ListForScope(ctx context.Context, scope string) (result RoleManagementPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleManagementPoliciesClient.ListForScope") + defer func() { + sc := -1 + if result.rmplr.Response.Response != nil { + sc = result.rmplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listForScopeNextResults + req, err := client.ListForScopePreparer(ctx, scope) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPoliciesClient", "ListForScope", nil, "Failure preparing request") + return + } + + resp, err := client.ListForScopeSender(req) + if err != nil { + result.rmplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPoliciesClient", "ListForScope", resp, "Failure sending request") + return + } + + result.rmplr, err = client.ListForScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPoliciesClient", "ListForScope", resp, "Failure responding to request") + return + } + if result.rmplr.hasNextLink() && result.rmplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListForScopePreparer prepares the ListForScope request. +func (client RoleManagementPoliciesClient) ListForScopePreparer(ctx context.Context, scope string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleManagementPolicies", 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 RoleManagementPoliciesClient) ListForScopeSender(req *http.Request) (*http.Response, error) { + return client.Send(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 RoleManagementPoliciesClient) ListForScopeResponder(resp *http.Response) (result RoleManagementPolicyListResult, err error) { + err = autorest.Respond( + resp, + 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 RoleManagementPoliciesClient) listForScopeNextResults(ctx context.Context, lastResults RoleManagementPolicyListResult) (result RoleManagementPolicyListResult, err error) { + req, err := lastResults.roleManagementPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.RoleManagementPoliciesClient", "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.RoleManagementPoliciesClient", "listForScopeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListForScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPoliciesClient", "listForScopeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListForScopeComplete enumerates all values, automatically crossing page boundaries as required. +func (client RoleManagementPoliciesClient) ListForScopeComplete(ctx context.Context, scope string) (result RoleManagementPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleManagementPoliciesClient.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) + return +} + +// Update update a role management policy +// Parameters: +// scope - the scope of the role management policy to upsert. +// roleManagementPolicyName - the name (guid) of the role management policy to upsert. +// parameters - parameters for the role management policy. +func (client RoleManagementPoliciesClient) Update(ctx context.Context, scope string, roleManagementPolicyName string, parameters RoleManagementPolicy) (result RoleManagementPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleManagementPoliciesClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, scope, roleManagementPolicyName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPoliciesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPoliciesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPoliciesClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client RoleManagementPoliciesClient) UpdatePreparer(ctx context.Context, scope string, roleManagementPolicyName string, parameters RoleManagementPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleManagementPolicyName": autorest.Encode("path", roleManagementPolicyName), + "scope": scope, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.ID = nil + parameters.Name = nil + parameters.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client RoleManagementPoliciesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client RoleManagementPoliciesClient) UpdateResponder(resp *http.Response) (result RoleManagementPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/authorization/mgmt/2020-10-01-preview/authorization/rolemanagementpolicyassignments.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/rolemanagementpolicyassignments.go new file mode 100644 index 000000000000..29e30c8d004b --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/rolemanagementpolicyassignments.go @@ -0,0 +1,381 @@ +package authorization + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RoleManagementPolicyAssignmentsClient is the client for the RoleManagementPolicyAssignments methods of the +// Authorization service. +type RoleManagementPolicyAssignmentsClient struct { + BaseClient +} + +// NewRoleManagementPolicyAssignmentsClient creates an instance of the RoleManagementPolicyAssignmentsClient client. +func NewRoleManagementPolicyAssignmentsClient(subscriptionID string) RoleManagementPolicyAssignmentsClient { + return NewRoleManagementPolicyAssignmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRoleManagementPolicyAssignmentsClientWithBaseURI creates an instance of the RoleManagementPolicyAssignmentsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewRoleManagementPolicyAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) RoleManagementPolicyAssignmentsClient { + return RoleManagementPolicyAssignmentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create a role management policy assignment +// Parameters: +// scope - the scope of the role management policy assignment to upsert. +// roleManagementPolicyAssignmentName - the name of format {guid_guid} the role management policy assignment to +// upsert. +// parameters - parameters for the role management policy assignment. +func (client RoleManagementPolicyAssignmentsClient) Create(ctx context.Context, scope string, roleManagementPolicyAssignmentName string, parameters RoleManagementPolicyAssignment) (result RoleManagementPolicyAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleManagementPolicyAssignmentsClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreatePreparer(ctx, scope, roleManagementPolicyAssignmentName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPolicyAssignmentsClient", "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.RoleManagementPolicyAssignmentsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPolicyAssignmentsClient", "Create", resp, "Failure responding to request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client RoleManagementPolicyAssignmentsClient) CreatePreparer(ctx context.Context, scope string, roleManagementPolicyAssignmentName string, parameters RoleManagementPolicyAssignment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleManagementPolicyAssignmentName": autorest.Encode("path", roleManagementPolicyAssignmentName), + "scope": scope, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.ID = nil + parameters.Name = nil + parameters.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}", 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 RoleManagementPolicyAssignmentsClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(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 RoleManagementPolicyAssignmentsClient) CreateResponder(resp *http.Response) (result RoleManagementPolicyAssignment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a role management policy assignment +// Parameters: +// scope - the scope of the role management policy assignment to delete. +// roleManagementPolicyAssignmentName - the name of format {guid_guid} the role management policy assignment to +// delete. +func (client RoleManagementPolicyAssignmentsClient) Delete(ctx context.Context, scope string, roleManagementPolicyAssignmentName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleManagementPolicyAssignmentsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, scope, roleManagementPolicyAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPolicyAssignmentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPolicyAssignmentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPolicyAssignmentsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client RoleManagementPolicyAssignmentsClient) DeletePreparer(ctx context.Context, scope string, roleManagementPolicyAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleManagementPolicyAssignmentName": autorest.Encode("path", roleManagementPolicyAssignmentName), + "scope": scope, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}", 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 RoleManagementPolicyAssignmentsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(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 RoleManagementPolicyAssignmentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the specified role management policy assignment for a resource scope +// Parameters: +// scope - the scope of the role management policy. +// roleManagementPolicyAssignmentName - the name of format {guid_guid} the role management policy assignment to +// get. +func (client RoleManagementPolicyAssignmentsClient) Get(ctx context.Context, scope string, roleManagementPolicyAssignmentName string) (result RoleManagementPolicyAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleManagementPolicyAssignmentsClient.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, roleManagementPolicyAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPolicyAssignmentsClient", "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.RoleManagementPolicyAssignmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPolicyAssignmentsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RoleManagementPolicyAssignmentsClient) GetPreparer(ctx context.Context, scope string, roleManagementPolicyAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "roleManagementPolicyAssignmentName": autorest.Encode("path", roleManagementPolicyAssignmentName), + "scope": scope, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}", 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 RoleManagementPolicyAssignmentsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(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 RoleManagementPolicyAssignmentsClient) GetResponder(resp *http.Response) (result RoleManagementPolicyAssignment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListForScope gets role management assignment policies for a resource scope. +// Parameters: +// scope - the scope of the role management policy. +func (client RoleManagementPolicyAssignmentsClient) ListForScope(ctx context.Context, scope string) (result RoleManagementPolicyAssignmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleManagementPolicyAssignmentsClient.ListForScope") + defer func() { + sc := -1 + if result.rmpalr.Response.Response != nil { + sc = result.rmpalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listForScopeNextResults + req, err := client.ListForScopePreparer(ctx, scope) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPolicyAssignmentsClient", "ListForScope", nil, "Failure preparing request") + return + } + + resp, err := client.ListForScopeSender(req) + if err != nil { + result.rmpalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPolicyAssignmentsClient", "ListForScope", resp, "Failure sending request") + return + } + + result.rmpalr, err = client.ListForScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPolicyAssignmentsClient", "ListForScope", resp, "Failure responding to request") + return + } + if result.rmpalr.hasNextLink() && result.rmpalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListForScopePreparer prepares the ListForScope request. +func (client RoleManagementPolicyAssignmentsClient) ListForScopePreparer(ctx context.Context, scope string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments", 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 RoleManagementPolicyAssignmentsClient) ListForScopeSender(req *http.Request) (*http.Response, error) { + return client.Send(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 RoleManagementPolicyAssignmentsClient) ListForScopeResponder(resp *http.Response) (result RoleManagementPolicyAssignmentListResult, err error) { + err = autorest.Respond( + resp, + 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 RoleManagementPolicyAssignmentsClient) listForScopeNextResults(ctx context.Context, lastResults RoleManagementPolicyAssignmentListResult) (result RoleManagementPolicyAssignmentListResult, err error) { + req, err := lastResults.roleManagementPolicyAssignmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "authorization.RoleManagementPolicyAssignmentsClient", "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.RoleManagementPolicyAssignmentsClient", "listForScopeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListForScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authorization.RoleManagementPolicyAssignmentsClient", "listForScopeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListForScopeComplete enumerates all values, automatically crossing page boundaries as required. +func (client RoleManagementPolicyAssignmentsClient) ListForScopeComplete(ctx context.Context, scope string) (result RoleManagementPolicyAssignmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleManagementPolicyAssignmentsClient.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) + return +} diff --git a/services/preview/authorization/mgmt/2020-10-01-preview/authorization/version.go b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/version.go new file mode 100644 index 000000000000..c73a55c84a3c --- /dev/null +++ b/services/preview/authorization/mgmt/2020-10-01-preview/authorization/version.go @@ -0,0 +1,19 @@ +package authorization + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " authorization/2020-10-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}